dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the...

282
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

Transcript of dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the...

Page 1: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 2: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

ACCEPTANCE SHEET

The Special Problem entitled “Healthy Eating Alert System: FoodIntake Monitor” prepared and submitted by Precious Joy U. Dizon in partialfulfillment of the requirements for the degree of Bachelor of Science in ComputerScience has been examined and is recommended for acceptance.

Avegail D. Carpio, M.Sc.Adviser

EXAMINERS:Approved Disapproved

1. Gregorio B. Baes, Ph.D. (candidate)2. Avegail D. Carpio, M.Sc.3. Perlita E. Gasmen, M.Sc. (candidate)4. Ma. Sheila A. Magboo, M.Sc.5. Vincent Peter C. Magboo, M.D., M.Sc.6. Bernie B. Terrado, M.Sc. (candidate)

Accepted and approved as partial fulfillment of the requirements for thedegree 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 SciencesDepartment of Physical Sciences and Mathematics

and Mathematics

Alex C. Gonzaga, Ph.D., Dr.Eng.Dean

College of Arts and Sciences

i

Page 3: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 4: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 . . . . . . . . . . . . . . . . . 37

iii

Page 5: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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. Database Structure . . . . . . . . . . . . . . . . . . . . . . . . . 48

C..1 Entity Relationship Diagram . . . . . . . . . . . . . . . . . . 48

C..2 Data Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . 49

V. Architecture 57

A. System Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 57

B. Technical Architecture . . . . . . . . . . . . . . . . . . . . . . . 57

VI. Results 59

A. 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

Page 6: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 7: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 8: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 9: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 10: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 11: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

29 recommended daily meals table . . . . . . . . . . . . . . . . . . . . 54

30 shared achievements table . . . . . . . . . . . . . . . . . . . . . . . 54

31 health tips table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

32 ingredients table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

33 ingredients recommended table . . . . . . . . . . . . . . . . . . . . 55

34 food exchange list table . . . . . . . . . . . . . . . . . . . . . . . . 56

35 health conditions restrictions table . . . . . . . . . . . . . . . . . . 56

x

Page 12: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 ma-

terial 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 nutri-

tional 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 limita-

tions 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 condi-

tions. 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 com-

pounded 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

Page 13: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 informa-

tion 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, gen-

der, weight, height and health conditions.

2

Page 14: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 Face-

book or Twitter

2. Allow the Content Manager to

(a) Input and Share Recommended Recipes with the Corresponding Nu-

tritional 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

Page 15: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 un-

healthy 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 con-

tents 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

Page 16: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 17: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 to-

ward 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 com-

prehensive nutritional intake information capture which may include: Food Type

(where no food identifier is available), Food Portion Size, Food Identifier Infor-

mation (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, Esti-

mation 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, spread-

sheets, 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 lactat-

6

Page 18: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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, al-

lows 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 un-

trained 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 sym-

bolic graphical representation[16]. It provides a convenient way of recording a

users diet, but in the current state, the image-processing algorithms for estimat-

ing 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 calo-

ries 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

Page 19: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 20: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

III. Theoretical Framework

A. 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

Page 21: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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]:

Table 1: The Calorie Need for MaleAge group (year) Weight (kg) Height (cm) Energy (kcal) Protein (gr) Activity

3-9 12 90 1500 35 Normal10-12 30 135 2000 45 Normal13-15 45 150 2400 69 Normal16-19 56 160 2500 66 Normal20-59 62 165 2800 55 Light20-59 62 165 3600 55 Medium20-59 62 165 3600 55 Heavy60+ 62 165 2200 55 Normal

Table 2: The Calorie Need for FemaleAge group (year) Weight (kg) Height (cm) Energy (kcal) Protein (gr) Activity

3-9 12 90 1500 35 Normal10-12 35 149 1900 54 Normal13-15 46 153 21200 62 Normal16-19 50 156 2000 51 Normal20-59 54 156 2050 48 Light20-59 54 156 2250 48 Medium20-59 54 156 2600 48 Heavy60+ 54 54 1850 48 Normal

10

Page 22: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 3: The Calorie Need for Pregnancy and Lactating

Age group (year) Weight (kg) Height (cm) Energy (kcal) Protein (gr) Activity

- - - +285 +12 Pregnant0-6 month - - +70 +16 Lactating7-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

Page 23: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

BMI Classification and Nutritional Status can be seen in Table 4[15]:

Table 4: Body Mass Index

BMI Classification Nutritional Status

<18.5 Under weight Malnutrition18.5 - 24.9 Healthy weight Normal25.0 - 34.9 Over weight Over Nutrition>35.0 Obese Very Excess Nutrition

D. 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 ex-

change 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

Page 24: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 5: Composition of Food Exchanges

List Food Measure (g) Carbohydrate (g) Protein Fat Energy

(Kcal) (Kj)

I-A Veg. A 1 cup raw12 cup cooked

I-A Veg. A 2 cups raw 3 1 16 671 cup cooked or

I-B Veg. B 12 cup 3 1 16 67raw12 cup

cookedII Fruit varies 10 40 167III Milk

Whole varies 12 8 10 170 711Low Fat 4 tbsp 12 8 5 125 523Skimmed varies 12 8 tr 80 335

IV Rice varies 23 2 100 418V Meat

Low Fat varies 8 1 41 172Medium Fat varies 8 6 86 360

High Fat varies 8 10 122 510VI Fat 1tbsp 5 45 188

Table 6: Vegetable Exchanges Equivalent

CHO PRO FAT ENERGY

(g) (g) (g) (KCalories)Group A - - - -Group B 3 1 - 16

13

Page 25: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Group A vegetables contain negligible carbohydrates, protein, and energy if 1 ex-

change 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 12

cup cooked (45g)

Vegetable B: 1 exchange = 12

cup raw (40g) or 12

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

Page 26: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 7: Vegetable Exchanges

Group A Group B

Acelgas Fresh; Abitsuela, bunga (snap green beans pod)Alagaw Leaves Carrot

Alugbati Leaves Coconut ShootAmpalaya Fruit Cowpea, pods (bunga)

Balbalulang (Seaweed) Lima, beans, pods (patani)Bamboo Shoot (Labong) Langka, hilaw

Banana Heart (Puso ng Saging) Mungbean Sprout (toge)Bataw Pods Pigeon Pea Pods

Beets RimasCabbage Singkamas Pods (bunga)

Camote Leaves Singkamas Tuber (lamang gubat)Cassava Leaves and Tops Squash Fruit

Cauliflower Stringbeans Pod (sitaw, bunga)Celery

Chayote FruitChayote Leaves

CucumberEggplant

Gabi LeavesHimbabaoKangkongKaturay

Katuray FlowersLettuce

Malunggay LeavesMalunggay PodsMushroom FreshMustard Leaves

OkraOnion Bulb

PakoPapaya Green

PatolaPepper Fruit

Pepper LeavesPetchay

Pokpoklo (seaweed)RadishSaluyot

Sigarilyas PodsSpinach

Squash Flower (kalabasa, bulaklak)Squash Leaves (kalabasa, dahon)

Sweet pea pods (sitsaro)TalinumTomatoUnsoyUpo

15

Page 27: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 8: ProcessedFOOD Weight (g) MEASURE

Edible Portion

Asparagus Tips 90 1 cupBaby Corn 15 2 (8 cm long x 5-12 cm

circumference each)Green Peas, canned (gisantes, canned) 15 1 tablespoon

Golden Sweet Corn, canned 20 2 tablespoonsMushroom, canned 110 1

3 cupTomato Juice, canned 60 1

2 cup undilutedWater Chestnut, canned 25 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

Page 28: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 9: Fruit Exchange

FOOD Weight (g) MEASURE

Fresh: A. P. E.P.

Anonas 65 35 12 of 5 x 8 cm

Apple 86 65 12 of 8 cm diameter or 1 (6 cm diameter)

Atis 70 45 1 (5 cm diameter)Balimbing 153 135 1 1

2 of 9 x 5 cmBanana

Bungulan 60 40 12 of 15 x 4 cm

Lakatan 51 40 1 (9 x 3 cm)Saba 70 40 1 (1 x 4 cm)

Cashew 78 70 1 (7 x 6 -12 cm)Chico 54 45 1 (4 cm diameter)

Dalanghita 300 135 2 (6 cm diameter each)Datiles 61 50 1 cupDuhat 80 60 20 (2 cm diameter each)Durian 150 130 1 segment of 6 - 2

3 x 4 12 cm or 1 1

2 tbsp.Grapes 69 55 10 (2 cm diameter each) or 4 (3 cm diameter each)Guava 81 80 2 (4 cm diameter each)

Guyabano 86 60 1 slice (8 x 6 x 2 cm) or 12 cup

Jackfruit, ripe 118 40 3 segments (6 cm diameter each)Kamachile 110 55 7 podsLanzones 103 70 7 (4 x 2 cm each)Lychees 77 50 5 (3 cm diameter each)Mabolo 83 50 2

3 of 6 cm diameterMakopa 169 135 3 (4 cm diameter each)

Mango, green 90 65 1 slice (11 x 6 cm)Medium ripe 90 65 1 slice (11 x 6 cm)

Ripe 103 60 1 slice (12 x 7 cm) 12 cup cubed

Indian 140 80 1 (6 cm diameter)Paho 92 70 9 small

Mangosteen 212 55 3 (6 cm diameter each)Marang 21 35 1

2 of 12 x 10 cmMelonKastila 317 200 1 slice (12 x 10 x 3 cm) or 1 - 1

3 cupPapaya, ripe 133 85 1 slice (10 x 6 x 2 cm) or 3

4 cupPear 118 85 1 slice (10 x 6 x 2 cm) or 1

2 cupRambutan 139 50 8 (3 cm diameter each)

Santol 127 75 1 (7 cm diameter each)Singkamas tuber 124 110 1

2 of (9 cm diameter each) or 1 cupSiniguelas 78 50 5 (3 cm diameter each)Star Apple 123 65 1

2 of 6 cm diameterStrawberry 168 165 1 1

4 cupsSuha 160 90 3 segments (8 x 4 x 3 cm each)

Tamarind, ripe 34 15 2 of 6 cm diameterTiesa 41 30 1

4 of 10 cm diameterWatermelon 226 140 1 slice (12 x 6 x 3 cm) or 1 cup

17

Page 29: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 10: Milk Exchanges Equivalent

CHO PRO FAT ENERGY

(KCalories)

Whole Milk 12 8 10 170Low Fat Milk 12 8 5 125

Skimmed/Very Low Fat Milk 12 8 Trace 80

Table 11: Milk Exchanges

FOOD Weight (g) MEASURE

A.P. / E.P.

*Whole MilkMilk, evaporated undiluted 125 1

2cup

Milk, evaporated filled undiluted 125 12

cupMilk, fresh carabao’s 250 1 cup

Milk, fresh cow’s 250 1 cupMilk, powdered 30 1

4cup or 4 level tbsp.

*Low Fat MilkPowdered 30 1

4cup or 4 level tbsp

Lite Low Fat Milk 250 1 tetra-brick*Skimmed (Non-Fat)/Very Low Fat Milk

Buttermilk Liquid 185 2/3 cupPowdered 25 1

4cup or 4 level tbsp

Long Life Skimmed Milk 250 1 cupYoghurt 125 1

2cup

18

Page 30: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 12: Rice Exchanges

FOOD Weight (g) MEASURE

A.P. / E.P.

A. RICE AND RICE PRODUCTS1. Rice, cooked 80 1

2 cup,packed2. Rice, gruel (lugaw)

Thin consistency 705 4-12 cupsMedium consistency 435 3 cupsThick consistency 250 1-12 cups

B. RICE EQUIVALENTS1. Bread

Pan Americano 40Pan de Bonete 40Pan de Leche 40Pan de Monay 40

Pan de Sal Rolls 40(hotdog/hamburger)Whole wheat bread

452. Corn and Corn Products

Binatog 90Corn/Rice curls and the like 25

Corn, boiled 120 65Baby corn 90

3. Noodles, cooked Bihon 75 1 cupMacaroni,Sotanghon,Spaghetti

4. Oatmeal 185 1 cup5. RootcropsSweet Potato 91 80 1

2 of 11 cmlong x 4-12 cm

diameter or 12 cup

Cassava 115 85 1 (5cm long x 4 cmdiameter) or 1 cup

Gabi 130 100 2 (6cm long x 4cmdiameter each) or 1 cup

Potato 195 165 2-12 (7 cm long x 4cmdiameter each) or 1-13 cups

Ube 155 130 1 (8-12 cm long x4-12 cm diameter)

6. Beans and NutsChestnuts, roasted 55 40 11 pieces large

or(Kastanyas, binusa) 20 pieces small

7. OtherCornstarch 25 5 teaspoons

Flour, all purpose 25 3 tablespoonsSago, cooked 120 1

2 , cooked

19

Page 31: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 ENERGY

(KCalories)

Low Fat Meat and Fish - 8 1 41Medium Fat Meat and Fish - 8 6 86

High Fat Meat and Fish - 8 10 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

x 1 - 12

cm)

Tenderloin (solomilyo),

Sirloin Steak (tagiliran, hulihan)

Centerloin (tagiliran, unahan)

b. Carabeef

Shank (bias) round (hita)

Continued on next page

20

Page 32: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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-12

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-12

x 1- 12

cm)

d. Chicken

Leg (hita) or 30 1 small leg

(13 - 12

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 14

breast (6cm long)

2. Variety Meats/ Internal Organs

Blood (dugo)

- pork, beef, chicken

Continued on next page

21

Page 33: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 34

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, lapu-

lapu, etc,) 35 1 slice (7 x 3 x 2 cm)

Medium Variety:

Hasa-hasa, dalagang bukid 35 1 (18 x 4-12

cm)

Galunggong 35 1 (14 x 3-12

cm)

Continued on next page

22

Page 34: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 14 – Continued from previous page

FOOD Wt. (g) MEASURE

E. P. cooked

Hito 35 12

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 - 12

x 3 cm each)

Dilis 35 14

cup

4. Other Seafoods

Alamang, tagunton 30 1-14

tablespoons

Aligue:

Alimango 15 1 tablespoon

Alimasag 50 3 tablespoons

Alimango/Alimasag, laman 20 14

cup or

12

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 12

cup

Squid (pusit) 25 3 (7 x 3 cm each)

Shells: Halaan 75 13

cup shelled or

3 cups with shell

Kuhol 50 12

cup shelled or

3 cups with shell

Susong pilipit 65 13

cup shelled or

Continued on next page

23

Page 35: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 14 – Continued from previous page

FOOD Wt. (g) MEASURE

E. P. cooked

2 cups with shell

Paros 60 1 cup shelled or

2-23

cups with shell

5. Beans

Pigeon pea seeds, dried (kadyos, buto, tuyo) 55 13

cup

6. Cheese

Cottage cheese 60 13

cup

7. Processed Foods

Dried:

Daing:

Alakaak, Alumahan, 20 1 (15-12

x 8 cm)

Bisugo, Biyang puti

Lapu-lapu 20 14

of 30 x 40 cm

Sapsap 20 3 (9 x 5 cm each)

Tamban 20 1 (16 x 3 cm)

Tinapa:

Bangus 30 14

of 20 x 8 cm

Galunggong 30 1 (16 x 4 cm)

Tamban 25 1 (16 x 5 cm)

Tuyo:

Alamang 15 13

cup

Ayungin, dilis sapsap 20 3 (11 - 12

x 8cm each)

Tunsoy 15 1 (8 x 1 cm)

Continued on next page

24

Page 36: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 14 – Continued from previous page

FOOD Wt. (g) MEASURE

E. P. cooked

Pusit

Canned:

Salmon 40 13

cup flaked

Tuna in brine 30 13

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

I. Lean Meat

a. Beef

Flank (kabilugan) 30 1 slice

matchbox size

(5 x 3-12

12

x 1-12

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 14

cup

Meats/Internal Organs

Continued on next page

25

Page 37: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 15 – Continued from previous page

FOOD Wt. (g) E. P. cooked MEASURE

Brain (utak)

- pork, beef, carabeef

3. Fish

Carpa 35 1 slice

(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

5. Cheese

Cheese, cheddar 35 1 slice

(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 12

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

Page 38: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 15 – Continued from previous page

FOOD Wt. (g) E. P. cooked MEASURE

canned

b. Meat Products

Corned beef 40 3 tablespoons

Ham sausage 55 3 of 9cm diameter

x 0.3 thick each

c. Bean Products

Soybean cheese,

soft (tofu) 100 12

cup

Soybean cheese, 60 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

1. Pork

Ham (pigue) 35 1 slice (3 cm cube)

2. Variety

meats/internal organ

Tongue (dila) - pork,

beef 35 34

cup

3.Egg

Duck’s egg 70 1 piece

Balut 65 1 piece

Penoy 60 1 piece

Continued on next page

27

Page 39: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 16 – Continued from previous page

FOOD Wt. (g) E. P. cooked MEASURE

4. Nuts

Peanuts, roasted 25 13

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 60 1-12

of

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

Page 40: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 17 – Continued from previous page

FOOD Wt. (g) E. P. cooked MEASURE

rapeseed-canola, rice

sunflower, safflower and

sesame 5 1 teaspoon

MONOUNSATURATED

FATS

pili nut 5 5 pieces

peanut oil, olive oil 5 1 teaspoon

shortening 5 1 teaspoon

E. Health Conditions

A persons diet may be different from the usual depending on certain health con-

ditions. 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 insulin-

dependent 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

Page 41: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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, 30-

45 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 2,500

Meal Plans

(Daily)

Starch 5 7 8 9 11Fruit 3 3 4 4 6Milk 2 2 3 3 3

Vegetables 2 2 3 4 5Meat and 4 4 6 6 8

Meat SubstitutesFat 3 4 4 5 6

Hypertension is having a high blood pressure[29]. According to the Philippine

Society of Hypertension (PSH), more than 10 million Filipinos suffer from hy-

pertension 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 satu-

rated 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

Page 42: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 19: Dietary Approach to Stop Hypertension

Food Group Daily Servings Serving Sizes Examples and Significance of

(except as) Notes Each Food

noted) Group to the

DASH Eating

Plan

Grains and 7-8 1 slice bread Whole wheat Major

Grain Products 1 oz dry cereal* bread, English sources of energy

12 cup cooked muffin, pita and fiber

rice, pasta, or bread, bagel

cereal cereals, grits

oatmeal

crackers

unsalted pretzels

and popcorn

Vegetables 4-5 12 cup cooked Tomatoes, Rich sources of

vegetable potatoes, potassium,

6oz vegetable carrots, green magnesium and

juice peas, squash, fiber

broccoli, turnip,

greens, collards,

kale, spinach,

artichokes,

green beans,

lima beans,

sweet potatoes

Fruits 4-5 6 oz fruit juice Apricots, Important

1 medium fruit bananas, dates sources of

14 cup dried grapes, oranges potassium,

fruit orange juice, magnesium and

12 cup fresh, grapefruit fiber

frozen or grapefruit juice,

canned fruit mangoes,

Continued on next page

31

Page 43: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 8 oz milk Fat free (skim) Major sources

free dairyfoods 1 cup yogurt or low fat (1 %) of calcium

1 12 oz cheese milk, fat free and protein

or lowfat

buttermilk,

fat free

or lowfat

regular or

frozen yogurt,

lowfat and

fat free cheese

Meats, poultry, 2 or less 3oz cooked Select only lean: Rich sources of

and fish 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 4-5 per week 13 cup or 1 1

2 Almonds, Rich sources

dry beans oz nuts filberts, mixed of energy,

2 Tbsp or 12 oz nuts, peanut,

seeds walnuts, magnesium,

Continued on next page

32

Page 44: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

12 cup cooked sunflower seeds, potassium,

dry beans kidney beans, protein and

lentils, peas fiber

Fats and oils ** 2-3 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

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

12 oz jelly beans gelatin, jelly

8 oz lemonade beans, hard

candy, fruit

punch, sorbet,

ices

*Equals 12-1 1

4cup, 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 12

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

Page 45: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 technolo-

gies 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 qual-

ifies 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

Page 46: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 47: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

IV. Design and Implementation

A. 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

Page 48: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

istered users can browse. Lastly, the Administrator is responsible for account

management, with functionalities such as creating another administrator or con-

tent manager, activation/deactivation of accounts and editing of account details,

and data backup.

B. Use Cases

B..1 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 Con-

tent 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

Page 49: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 50: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 51: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

B..4 Input Health Tips

Figure 5: Activity Diagram: HEAS:FIM Input Health Tips

40

Page 52: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

B..5 Browse Recipes, Food Nutritional Contents, Health Tips

Figure 6: Activity Diagram: HEAS:FIM Browse Recipes, Food Nutritional Con-tents, Health Tips

41

Page 53: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

B..6 Account Management

Figure 7: Use Case (HEAS:FIM Account Management)

Figure 7 shows that the Administrator shall manage accounts. He/she can man-

ually add user (Figure 8), view users (Figure 9), delete user (Figure 10), and

manage password (Figure 11).

42

Page 54: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 55: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 56: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 57: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 58: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

B..11 Plan Daily Meals

Figure 12: Flow Chart: HEAS:FIM Plan Daily Meals

47

Page 59: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

C. Database Structure

C..1 Entity Relationship Diagram

Figure 13: HEAS:FIM Entity Relationship Diagram

Figure 13 shows the Entity Relationship Diagram of the HEAS:FIM. Each regis-

tered 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 ta-

ble) 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 rec-

ommend 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 restric-

tions for Diabetes, Hypertension, and Kidney Stones.

48

Page 60: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

C..2 Data Dictionary

Table 20: users tableAttribute Data Type Description

user id int (20) Primary Key,User ID

username varchar (20) User Usernamepassword varchar (50) User Password

confirm password varchar (50) User Confirm Passwordfirst name varchar (20) User First Name

middle name varchar (20) User Middle Name (optional)last name varchar (20) User Last Nameuser type enum (’Administrator’,

’Content Manager’, ’User’) User User Typeemail address varchar (50) User E-mail Address

gender enum (’Male’, ’Female’) User Genderbirthday date User Date of Birthstatus enum (’Activated’, ’Deactivated’) User Account Status

49

Page 61: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

goal weight float Stores the Goal Weightentered by the

Registered Usercurrent weight float Stores the Current Weight

entered by theRegistered User

height float Stores the Heightentered by the

Registered Usercalorie limit float Daily Calorie Limit

of the Registered Userin Kcal

carbohydrate limit float Daily Carbohydrate Limitof the Registered User

in gprotein limit float Daily Protein Limit

of the Registered Userin g

fat limit float Daily Fat Limitof the Registered User

in grecord date date Date when the

record was entered

50

Page 62: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 22: health conditions tableAttribute Data Type Description

health condition id int (20) Primary Key,Health Condition ID

user id int (20) Foreign Key,References users

(user id),User ID

fitness info id int (20) Foreign Key,References fitness profile

(fitness info id),Fitness Info ID

health condition set (’Diabetes’,’Hypertension’, Health Condition’Kidney Stones’,’None’)

record date date Date when therecord was entered

Table 23: own recipes table

Attribute Data Type Description

own recipe id int (20) Primary Key,Own Recipe ID

user id int (20) Foreign Key,References users

(user id),User ID

health condition set (’Diabetes’,’Hypertension’, Health Condition’Kidney Stones’,’None’)

meal type enum (’Breakfast’, ’Lunch’, Meal Type’Dinner, ’Snack’)

recipe name varchar (50) Recipe Nameserving sugg float Recipe Serving Size

preparation procedure longtext Recipe PreparationProcedure

calories float Recipe Calories in Kcalcarbohydrate float Recipe Carbohydrate in g

protein float Recipe Protein in gfat float Recipe Fat in g

51

Page 63: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 24: recommended recipes table

Attribute Data Type Description

recommended recipe id int (20) Primary Key,Recommended

Recipe IDuser id int (20) Foreign Key,

References users(user id),User ID

health condition set (’Diabetes’,’Hypertension’, Health Condition’Kidney Stones’,’None’)

meal type enum (’Breakfast’, ’Lunch,’ Meal Type’Dinner, ’Snack’)

recipe name varchar (50) Recipe Nameserving sugg float

preparation procedure longtext Recipe PreparationProcedure

calories float Recipe Calories in Kcalcarbohydrate float Recipe Carbohydrate in g

protein float Recipe Protein in gfat float 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

Page 64: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

img name varchar (40) Image Namethumb name varchar (40) Image Thumbnail Name

ext varchar (8) Image File Extensionupload 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

recommended recipe id int (20) Foreign Key,References recommended recipes

(recommended recipe id),Recommended Recipe ID

img name varchar (40) Image Namethumb name varchar (40) Image Thumbnail Name

ext varchar (8) Image File Extensionupload date varchar (20) Image Upload Date

Table 28: plan daily meals table

Attribute Data Type Description

plan daily meal id int (20) Primary Key,Plan Daily Meal 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

meal group enum (’Breakfast’, ’Lunch’, Meal Group’Dinner’, ’Snack’)

record date date Date when therecord was entered

53

Page 65: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 29: recommended daily meals table

Attribute Data Type Description

recommended daily meal id int (20) Primary Key,Recommended Daily

Meal IDuser id int (20) Foreign Key,

References users(user id),User ID

recommended recipe id int (20) Foreign Key,References

recommendedrecipes

(recommendedrecipe id),

RecommendedRecipe ID

meal group enum (’Breakfast’, ’Lunch’, Meal Group’Dinner’, ’Snack’)

record date date Date when therecord was entered

Table 30: shared achievements tableAttribute Data Type Description

shared achievement id int (20) Primary Key,Shared Achievement ID

user id int (20) Foreign Key,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 Tippost date date Date when the

record was posted

54

Page 66: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 32: ingredients table

Attribute Data Type Description

ingredient id int (20) Primary Key,Ingredient ID

own recipe id int (20) Foreign Key,References own recipes

(own recipe id),Own Recipe ID

food group varchar (50) Food Groupfood name varchar (50) Food Namemeasure varchar (50) Measure with Unit

serving size float 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

recommendedrecipes

(recommendedrecipe id),

RecommendedRecipe ID

food group varchar (50) Food Groupfood name varchar (50) Food Namemeasure varchar (50) Measure with Unit

serving size float Serving Size

55

Page 67: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

Table 34: food exchange list table

Attribute Data Type Description

food exchange list id int (20) Primary Key,Food Exchange

List IDlist group varchar (50) (’I-A’,’I-B’,’I-P’,’II’,’III’, List Group

’IV’,’V’,’VI’,’Other’)food group varchar (50) (’Vegetable’,’Fruit’,’Milk’, Food Group

’Rice’,’Meat’,’Fat’,’Other’)food group category varchar (50) (’Vegetable’,’Fruit’,’Milk’, Food Group

’Rice’,’Meat’,’Fat’,’Other’) + Categoryfood name varchar (50) Food Name

measure varchar (50) Measure with Unitcarbohydrate float Carbohydrate in g

protein float Protein in gfat float Fat in g

energy float Calories, in Kcalweight as purchased float Weight in gweight edible portion float Weight in g

Table 35: health conditions restrictions tableAttribute Data Type Description

health conditions restrictions id int (20) Primary Key,Health Conditions

Restrictions IDfood group varchar (50) Food Group

diabetes restriction float RestrictionQuantity byFood Group

hypertension restriction float RestrictionQuantity byFood Group

kidney stones restriction float RestrictionQuantity byFood Group

56

Page 68: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

V. Architecture

A. 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 Ser-

vice Layer is linked to the Presentation Layer through the Codeigniter Frame-

work 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 Moni-

tor:

• Web Server: Apache

• Database Server: MySQL

• MySQL Administration Tool: phpMyAdmin

• PHP Framework: CodeIgniter

57

Page 69: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

• Web Browser: best on Google Chrome

• Stable Internet Connection

• 1.4 GHz Solo Core

• 1 GB RAM

58

Page 70: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

VI. Results

A. General View

A..1 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

Page 71: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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. Administrator View

B..1 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

Page 72: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

B..2 Add User

Figure 18: Add User

By clicking the Add User button on the administrator home page, the adminis-

trator 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

Page 73: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

C. Content Manager View

C..1 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 con-

tent/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

Page 74: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 75: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

C..4 Add Content

Figure 23: Add Content

By clicking the Add Content button, links to add Food Exchange Item, Recom-

mended 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

Page 76: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 77: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 78: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 79: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 80: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 81: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

D. User View

D..1 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

Page 82: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 83: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 84: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 con-

sidering health conditions if any. (Figure 40).

73

Page 85: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 86: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 87: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 88: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 89: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 90: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 91: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

By selecting Recommended Daily Meals under Browse, the user can view recom-

mended 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

Page 92: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 ex-

isting 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 con-

sidering health conditions, current weight versus goal weight and calorie monitor,

recommendation of recipes, daily meals, and health tips, and sharing of achieve-

ments 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

Page 93: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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

Page 94: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 cre-

ation of recipes from scratch with corresponding calorific values and restriction

of the amount of ingredients considering health conditions that would be recom-

mended 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

Page 95: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

IX. Recommendations

Healthy Eating Alert System:Food Intake Monitor is a Health and Fitness ap-

plication 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 pow-

erful 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

Page 96: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 nutritional status affects your

health.” 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

Page 97: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

[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 Informat-

ics, 2013.

[15] D. S. Adriyendi, “Prediction nutrition status using body mass index on mo-

bile 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

Page 98: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

[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

Page 99: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

XI. Appendix

A. Forms

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#addFPButton , #addFPBackButton , #addFPHomeButton”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangemaxDate : ’ 0 ’ ,dateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;} ,gotoCurrent : t rue }) . da tep i cke r ( ’ setDate ’ , ” 0” ) ;

$ ( ”#addFPDialog” ) . d i a l og ({autoOpen : true ,width : 400 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

f unc t i on c o n f i rm a dd f i t n e s s p r o f i l e ( ) {// var cur r ent we ight = document . getElementById (” cur r ent we ight ”) . va lue ;// var goa l we ight = document . getElementById (” goa l we ight ”) . va lue ;// var he ight = document . getElementById (” he ight ”) . value ;// var h ea l t h cond i t i on = document . getElementById (” hea l t h cond i t i on ”) . va lue ;// var r e co rd date = document . getElementById (” r e co rd date ”) . va lue ;// var msg = ”Are you sure you want to submit the f o l l ow ing in format ion ?” + ”\n” + ”Current

Weight ( kg ) : ” + cur rent we ight + ”\n” + ”Goal Weight ( kg ) : ” + goa l we ight + ”\n” + ”Height (cm) : ” + he ight + ”\n” + ”Health Condit ion : ” + hea l t h cond i t i on + ”\n” + ”Record Date : ” +reco rd date ;

var msg = ”Are you sure you want to submit the f o l l ow ing in format ion ?” ;re turn conf irm (msg) ;}</s c r i p t></head><body><div id=”addFPDialog” t i t l e =”Add F i tne s s P r o f i l e In format ion ”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open ( ’ home user / a d d f i t n e s s p r o f i l e s a v e ’ ) ; ?><center><table><tr></tr><tr></tr><tr><td><l a b e l f o r=”cur r ent we ight”>&nbsp ; Current Weight ( kg ) :</ labe l><td><input id=”cur rent we ight ” name=”cur rent we ight ” type=”text ” value=”<?php echo s e t v a l u e

( ’ current we ight ’ ) ; ?>” ></tr><tr><td><l a b e l f o r=”goa l we ight”>&nbsp ; Goal Weight ( kg ) :</ labe l><td><input id=”goa l we ight ” name=”goa l we ight ” type=”text ” value=”<?php echo s e t v a l u e ( ’

goa l we ight ’ ) ; ?>” ></tr><tr><td><l a b e l f o r=”he ight”>&nbsp ; Height (cm) :</ labe l>

88

Page 100: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<td><input id=”he ight ” name=”he ight ” type=”text ” value=”<?php echo s e t v a l u e ( ’ height ’ ) ; ?>” ></tr><tr><td><l a b e l f o r=”hea l t h cond i t i on”>&nbsp ; Health Condit ion :</ labe l><td><input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Diabetes ” <?

php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (” Diabetes ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Diabetes<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Hypertension ” <?php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (” Hypertension ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Hypertension<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Kidney Stones ”<?php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (”Kidney Stones ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Kidney Stones<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”None” <?php i f( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (”None” , $ POST [” hea l t h cond i t i on ” ] ) ) ) {echo ” checked ” ;} ?>>None<br>

<!−−<td><s e l e c t id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on”><opt ion value=”Diabetes ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Diabetes ”) echo ” s e l e c t e d ”;?>>Diabetes</option><opt ion value=”Hypertension ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Hypertension ”) echo ” s e l e c t e d ”;?>>Hypertension</option><opt ion value=”Kidney Stones ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Kidney Stones ”) echo ” s e l e c t e d ”;?>>Kidney Stones</option><opt ion value=”None” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[” hea l t h cond i t i on ” ]

== ”None”) echo ” s e l e c t e d ”;?>>None</option></s e l e c t>−−></tr><!−−<tr><td><l a b e l f o r=”hea l t h c ond i t i o n s”>&nbsp ; Health Condit ions ( i f any , e . g . Diabetes Type I I ,

Hypertension , Kidney Stones ) :</ labe l><td><input id=”hea l t h c ond i t i o n s ” name=”hea l t h c ond i t i o n s ” type=”text ” value=”<?php echo

s e t v a l u e ( ’ h ea l th cond i t i on s ’ ) ; ?>” ></tr>−−><tr><td><l a b e l f o r=”reco rd date”>&nbsp ; Date:</ labe l><td><input id=”reco rd date ” name=”reco rd date ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value

=”<?php echo s e t v a l u e ( ’ r ecord date ’ ) ; ?>” readonly=”readonly”><a h r e f=”#reco rd date ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a></tr>

<tr><td><button id=”addFPButton” type=”submit” name=”submit” value=”submit” onc l i c k=”return

c o n f i rm a dd f i t n e s s p r o f i l e ( )”>Add Information</button><td><button id=”addFPBackButton” type=”button” name=”addFPBackButton” value=”Back” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”addFPHomeButton” type=”button” name=”addFPHomeButton” value=”Home” onc l i c k=”window

. l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#addFELItemButton , #addFELItemBackButton , #addFELItemHomeButton”) . button ( ) ;

$ ( ’ amf ’ ) . c s s ( ’ d i sp lay ’ , ’ none ’ ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#addFELItemDialog” ) . d i a l og ({autoOpen : true ,width : 750 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

89

Page 101: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ ( document ) . ready ( func t i on ( ) {$(”# l i s t g r o u p ”) . change ( func t i on ( ) {/∗dropdown post ∗///$ . ajax ({ur l :”<?php echoba s e u r l ( ) ;?> index . php/home cmanager/buildDropFEL” ,data : { l i s t g r o u p :$ ( t h i s ) . va l ( ) } ,type : ”POST” ,suc c e s s : f unc t i on ( data ){$(”#food group ”) . html ( data ) ;}}) ;toggleTextBox ( t h i s ) ;}) ;

$(”# l i s t g r o u p ”) . change ( func t i on ( ) {/∗dropdown post ∗///$ . ajax ({ur l :”<?php echoba s e u r l ( ) ;?> index . php/home cmanager/buildDropFEL2 ” ,data : { l i s t g r o u p :$ ( t h i s ) . va l ( ) } ,type : ”POST” ,suc c e s s : f unc t i on ( data ){$(”# food group category ”) . html ( data ) ;}}) ;toggleTextBox ( t h i s ) ;}) ;}) ;

f unc t i on toggleTextBox ( element ) {// a l e r t ( element . value ) ;i f ( element . value == ”Other ”) {i f ( document . getElementById ( element . id+”other ”) == nu l l )$ ( $ ( document . createElement (” input ”) ) . a t t r ({type : ” text ” ,id : element . id+”other ” ,name : element . name+”other ”}) ) . i n s e r tA f t e r ( element ) ;

} e l s e {$(”#”+element . id+”other ”) . remove ( ) ;}}</s c r i p t></head><body><div id=”addFELItemDialog” t i t l e =”Add Food Exchange L i s t Item”><br>

<f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open ( ’ home cmanager/ add f e l i t em save ’ ) ; ?><center><table><tr></tr><tr></tr><tr><td><l a b e l f o r=” l i s t g r o u p”>&nbsp ; L i s t Group:</ labe l><td><?php echo form dropdown ( ’ l i s t g r oup ’ , $lg , ’ ’ , ’ c l a s s=”requ i r ed ” id=” l i s t g r o u p ” ’ ) ; ?></tr><tr><td><l a b e l f o r=”food group”>&nbsp ; Food Group:</ labe l><td><s e l e c t id =”food group ” name=”food group ” c l a s s=”food group ” onchange=’ toggleTextBox ( t h i s

) ’><opt ion value=”” >Please s e l e c t Food Group</option></s e l e c t></tr><tr><td><l a b e l f o r=”food group category”>&nbsp ; Food Group Category :</ labe l><td><s e l e c t id =”food group category ” name=”food group category ” c l a s s=”food group category ”

onchange=’ toggleTextBox ( t h i s ) ’><opt ion value=””>Please s e l e c t Food Group Category</option></s e l e c t></tr><tr><td><l a b e l f o r=”food name”>&nbsp ; Food Name:</ labe l><td><input id=”food name” name=”food name” type=”text ” value=”<?php echo s e t v a l u e ( ’ food name

’ ) ; ?> ” ></tr><tr><td><l a b e l f o r=”measure”>&nbsp ; Measure :</ labe l><td><input id=”measure” name=”measure” type=”text ” value=”<?php echo s e t v a l u e ( ’ measure ’ ) ;

?>” ></tr><tr><td><l a b e l f o r=”carbohyrate”>&nbsp ; Carbohydrate ( g ) :</ labe l><td><input id=”carbohydrate ” name=”carbohydrate ” type=”text ” value=”<?php echo s e t v a l u e ( ’

carbohydrate ’ ) ; ?>” ></tr><tr><td><l a b e l f o r=”pro t e in”>&nbsp ; Prote in ( g ) :</ labe l><td><input id=”pro t e in ” name=”pro t e in ” type=”text ” value=”<?php echo s e t v a l u e ( ’ prote in ’ ) ;

?>” ></tr><tr><td><l a b e l f o r=”f a t”>&nbsp ; Fat ( g ) :</ labe l><td><input id=”f a t ” name=”f a t ” type=”text ” value=”<?php echo s e t v a l u e ( ’ fat ’ ) ; ?>” ></tr>

90

Page 102: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<tr><td><l a b e l f o r=”energy”>&nbsp ; Energy ( Kcal ) :</ labe l><td><input id=”energy ” name=”energy ” type=”text ” value=”<?php echo s e t v a l u e ( ’ energy ’ ) ; ?>” ></tr><tr><td><l a b e l f o r=”we ight as purchased”>&nbsp ; Weight as Purchased ( g ) :</ labe l><td><input id=”we ight as purchased ” name=”weight as purchased ” type=”text ” value=”<?php echo

s e t v a l u e ( ’ we ight as purchased ’ ) ; ?>” ></tr><tr><td><l a b e l f o r=”we i gh t ed i b l e po r t i on”>&nbsp ; Weight Edible Port ion ( g ) :</ labe l><td><input id=”we i gh t ed i b l e po r t i on ” name=”we i gh t ed i b l e po r t i on ” type=”text ” value=”<?php

echo s e t v a l u e ( ’ we i gh t ed ib l e po r t i on ’ ) ; ?>” ></tr><tr><td><button id=”addFELItemButton” type=”submit” name=”submit” value=”submit”>Add Item</button><td><button id=”addFELItemBackButton” type=”button” name=”addFELItemBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Back</button><button id=”addFELItemHomeButton” type=”button” name=”addFELItemHomeButton” value=”Home”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#addHealthTipButton , #addHealthTipBackButton , #addHealthTipHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#addHealthTipDialog ” ) . d i a l og ({autoOpen : true ,width : 530 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

</s c r i p t></head><body><div id=”addHealthTipDialog ” t i t l e =”Add Health Tip”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open ( ’ home cmanager/ add hea l th t ip save ’ ) ; ?><center><table><tr></tr><tr></tr><tr><td><t ex ta r ea rows=”4” c o l s =”50” id=”h e a l t h t i p ” name=”h e a l t h t i p ” type=”longtex t ” value=”<?

php echo s e t v a l u e ( ’ h ea l th t i p ’ ) ; ?>” ></textarea></tr><tr><td><button id=”addHealthTipButton” type=”submit” name=”submit” value=”submit”>Add Health Tip

</button><button id=”addHealthTipBackButton” type=”button” name=”addHealthTipBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Back</button><button id=”addHealthTipHomeButton” type=”button” name=”addHealthTipHomeButton” value=”Home”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

91

Page 103: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>

$ ( func t i on ( ) {

$ ( ”#addMealBackButton , #addMealButton , #addMealHomeButton” ) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangeminDate : ’ 0 ’ ,dateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;} ,gotoCurrent : t rue }) . da tep i cke r ( ’ setDate ’ , ” 0” ) ;

$ ( ”#addMealDialog” ) . d i a l og ({autoOpen : true ,width : 850 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;}) ;</s c r i p t></head><body><div id=”addMealDialog” t i t l e =”Add Meal”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open (” home cmanager/add meal / $recommended rec ipe id ”) ;?><center><table><t r s t y l e=”d i sp l ay : none;”><td><l a b e l f o r=”recommended rec ipe id”>&nbsp ; Recipe ID:</ labe l><td><input id=”recommended rec ipe id ” name=”recommended rec ipe id ” type=”text ” value=”<?php

echo $recommended rec ipe id ; ?>” readonly=”readonly”></tr><tr><td><l a b e l f o r=”reco rd date”>&nbsp ; For Date:</ labe l><td><input id=”reco rd date ” name=”reco rd date ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value

=”<?php echo s e t v a l u e ( ’ r ecord date ’ ) ; ?>” readonly=”readonly”><a h r e f=”#reco rd date ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a></tr><tr><td><l a b e l f o r=”meal group”>&nbsp ; For Meal:</ labe l><td><s e l e c t id=”meal group” name=”meal group”><opt ion value=”Breakfast ” <?php i f ( i s s e t ($ POST [” meal group ” ] ) && $ POST[” meal group ” ] == ”

Breakfast ”) echo ” s e l e c t e d ”;?>>Breakfast</option><opt ion value=”Lunch” <?php i f ( i s s e t ($ POST [” meal group ” ] ) && $ POST[” meal group ” ] == ”Lunch

”) echo ” s e l e c t e d ” ; ?>>Lunch</option><opt ion value=”Dinner” <?php i f ( i s s e t ($ POST [” meal group ” ] ) && $ POST[” meal group ” ] == ”

Dinner ”) echo ” s e l e c t e d ” ; ?>>Dinner</option><opt ion value=”Snack” <?php i f ( i s s e t ($ POST [” meal group ” ] ) && $ POST[” meal group ” ] == ”Snack

”) echo ” s e l e c t e d ” ; ?>>Snack</option></s e l e c t></tr><tr><td><button id=”addMealButton” type=”submit” name=”submit” value=”submit”>Add Meal</button><td><button id=”addMealBackButton” type=”button” name=”addMealBackButton” value=”Back” onc l i c k

=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager/ search meal ’”>Back</button><button id=”addMealHomeButton” type=”button” name=”addMealHomeButton” value=”Home” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

92

Page 104: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>

$ ( func t i on ( ) {

$ ( ”#addMealBackButton , #addMealButton , #addMealHomeButton” ) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangeminDate : ’ 0 ’ ,dateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;} ,gotoCurrent : t rue }) . da tep i cke r ( ’ setDate ’ , ” 0” ) ;

$ ( ”#addMealDialog” ) . d i a l og ({autoOpen : true ,width : 850 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;}) ;</s c r i p t></head><body><div id=”addMealDialog” t i t l e =”Add Meal”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open (” home user /add meal / $own rec ipe id ”) ;?><center><table><t r s t y l e=”d i sp l ay : none;”><td><l a b e l f o r=”own rec ipe id”>&nbsp ; Recipe ID:</ labe l><td><input id=”own rec ipe id ” name=”own rec ipe id ” type=”text ” value=”<?php echo

$own rec ipe id ; ?>” readonly=”readonly”></tr><tr><td><l a b e l f o r=”reco rd date”>&nbsp ; For Date:</ labe l><td><input id=”reco rd date ” name=”reco rd date ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value

=”<?php echo s e t v a l u e ( ’ r ecord date ’ ) ; ?>” readonly=”readonly”><a h r e f=”#reco rd date ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a></tr><tr><td><l a b e l f o r=”meal group”>&nbsp ; For Meal:</ labe l><td><s e l e c t id=”meal group” name=”meal group”><opt ion value=”Breakfast ” <?php i f ( i s s e t ($ POST [” meal group ” ] ) && $ POST[” meal group ” ] == ”

Breakfast ”) echo ” s e l e c t e d ”;?>>Breakfast</option><opt ion value=”Lunch” <?php i f ( i s s e t ($ POST [” meal group ” ] ) && $ POST[” meal group ” ] == ”Lunch

”) echo ” s e l e c t e d ” ; ?>>Lunch</option><opt ion value=”Dinner” <?php i f ( i s s e t ($ POST [” meal group ” ] ) && $ POST[” meal group ” ] == ”

Dinner ”) echo ” s e l e c t e d ” ; ?>>Dinner</option><opt ion value=”Snack” <?php i f ( i s s e t ($ POST [” meal group ” ] ) && $ POST[” meal group ” ] == ”Snack

”) echo ” s e l e c t e d ” ; ?>>Snack</option></s e l e c t></tr><tr><td><button id=”addMealButton” type=”submit” name=”submit” value=”submit”>Add Meal</button><td><button id=”addMealBackButton” type=”button” name=”addMealBackButton” value=”Back” onc l i c k

=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user / search meal ’”>Back</button><button id=”addMealHomeButton” type=”button” name=”addMealHomeButton” value=”Home” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

93

Page 105: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>var quant i ty ;$ ( func t i on ( ) {var data2 = [ ] ;var index = 0 ;

$ ( ”#addRecipeButton , #addRecipeBackButton , #addRecipeHomeButton” ) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;}}) ;$ ( ”#addRecipeDialog ” ) . d i a l og ({autoOpen : true ,width : 600 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;

var id ;$ ( ’ . i ng r ed i en t s ’ ) . autocomplete ({minLength : 0 ,source : func t i on ( request , re sponse ) {id = th i s . element . context . a t t r i b u t e s [ name=”id ” ] . va lue ;// conso l e . l og ( id ) ;$ . a jax ( {ur l : ”<?php echo s i t e u r l ( ’ home cmanager/ sugges t ions ’ ) ; ?>”,data : request ,dataType : ” j son ” ,type : ”POST” ,suc c e s s : func t i on ( data ) {// conso l e . l og (JSON. s t r i n g i f y ( data ) ) ;re sponse ( $ .map( data , func t i on (v , i ){i f ( v . measure != nu l l )data2 [ data2 . l ength ] = v . measure ;e l s e i f ( v . food name != nu l l )data2 [ data2 . l ength ] = v . food name ;e l s e i f ( v . energy != nu l l )data2 [ data2 . l ength ] = v . energy ;e l s e i f ( v . carbohydrate != nu l l )data2 [ data2 . l ength ] = v . carbohydrate ;e l s e i f ( v . p ro t e in != nu l l )data2 [ data2 . l ength ] = v . p ro t e in ;e l s e i f ( v . f a t != nu l l )data2 [ data2 . l ength ] = v . f a t ;e l s e i f ( v . food group != nu l l )data2 [ data2 . l ength ] = v . food group ;

re turn {l a b e l : v . food name} ;}) ) ;}}) ;} ,s e l e c t : func t i on ( event , u i ) {var num = id . subs t r i ng ( id . indexOf (” s ”) + 1 , id . l ength ) ;var measure = nu l l ;var food group = nu l l ;var c a l o r i e , carbohydrate , prote in , f a t ;f o r ( var i = 0 ; i < data2 . l ength ; i+=7){i f ( data2 [ i ] == ui . item . value ) {measure = data2 [ i + 1 ] ;c a l o r i e = data2 [ i + 2 ] ;carbohydrate = data2 [ i + 3 ] ;

94

Page 106: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

pro t e in = data2 [ i + 4 ] ;f a t = data2 [ i + 5 ] ;food group = data2 [ i +6] ;}}// conso l e . l og ( c a l o r i e ) ;$( ’# ingred ient measure ’+num) . va l ( measure ) ;$( ’# food group ’+num) . va l ( food group ) ;/∗$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) + +c a l o r i e ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) + +carbohydrate ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) + +prote in ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) + +fa t ) ;∗/}/∗ f o cus : func t i on ( event , u i ) {$ ( ” . i n g r ed i e n t s ” ) . va l ( u i . item . l a b e l ) ;} ,s e l e c t : func t i on ( event , u i ) {}∗/}) ;}) ;

f unc t i on update ( id ) {var reques t = new XMLHttpRequest ( ) , u r l = ”<?php echo s i t e u r l ( ’ home cmanager/ ge t f a ’ ) ; ?>”,

params = ” ing r ed i en t=”+$(”# ing r ed i e n t s”+id ) . va l ( ) ;

r eques t . onreadystatechange = func t i on ( ) {i f ( r eques t . readyState == 4 && reques t . s t a tu s == 200) {var temp = reques t . responseText . s p l i t ( ” , ” ) , i ;

$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) − (+temp [ 0 ] ∗ quant i ty [ id ] ) ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) − (+temp [ 1 ] ∗ quant i ty [ id ] ) ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) − (+temp [ 2 ] ∗ quant i ty [ id ] ) ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) − (+temp [ 3 ] ∗ quant i ty [ id ] ) ) ;

f o r ( i = 0 ; i < temp . l ength ; i++)temp [ i ] = +temp [ i ] ∗ $(”# ing r ed i en t quan t i t y”+id ) . va l ( ) ;

$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) + temp [ 0 ] ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) + temp [ 1 ] ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) + temp [ 2 ] ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) + temp [ 3 ] ) ;

quant i ty [ id ] = $(”# ing r ed i en t quan t i t y”+id ) . va l ( ) ;}}r eques t . open (”POST” , ur l , t rue ) ;r eques t . setRequestHeader (”Content−type ” , ” app l i c a t i on /x−www−form−ur lencoded ”) ;r eques t . send ( params ) ;}

$ ( document ) . ready ( func t i on ( ) {var counter = 1 ;var data2 = [ ] ;quant i ty = new Array ( ) ;

quant i ty [ 0 ] = $(”# ing r ed i en t quan t i t y0 ”) . va l ( ) == ”” ? 0 : $(”# ing r ed i en t quan t i t y0 ”) . va l ( ) ;

$(”#addIngredientButton ”) . c l i c k ( func t i on ( ) {

/∗ i f ( counter >10){a l e r t (”Only 10 textboxes a l low ”) ;re turn f a l s e ;} ∗/

quant i ty [ counter ] = 0 ;

var newTextBoxDiv = $ ( document . createElement ( ’ div ’ ) ) . a t t r (” id ” , ’TextBoxDiv ’ + counter ) ;newTextBoxDiv . a f t e r ( ) . html( ’<br><l abe l>I ng r ed i en t : &nbsp;&nbsp;&nbsp;</ labe l >’ +’< input type=”text ” c l a s s=” i n g r ed i e n t s ” name=”i ng r ed i e n t s [ ’+ counter + ’]” id=”ing r ed i en t s ’ +

counter + ’” value=”” > ’) ;

var newTextBoxDiv1= $ ( document . createElement ( ’ div ’ ) ) . a t t r (” id ” , ’ TextBoxDiv1 ’ + counter ) ;newTextBoxDiv1 . a f t e r ( ) . html( ’< l abe l>Measure ( g ) : </labe l >’ +’< input type=”text ” c l a s s=”measure” name=”ingred i ent measure [ ’+ counter + ’]” id=”

ingred ient measure ’ + counter + ’” value=”” > ’) ;

var newTextBoxDiv2= $ ( document . createElement ( ’ div ’ ) ) . a t t r (” id ” , ’ TextBoxDiv2 ’ + counter ) ;newTextBoxDiv2 . a f t e r ( ) . html( ’< l abe l>Quantity : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</ labe l >’ +’< input type=”text ” name=”ing r ed i en t quan t i t y [ ’+ counter + ’]” id=”ing r ed i en t quant i t y ’ + counter

+ ’” value=”” onchange=”update ( ’+ counter + ’)”> ’) ;

var newTextBoxDiv3= $ ( document . createElement ( ’ div ’ ) ) . a t t r (” id ” , ’ TextBoxDiv3 ’ + counter ) ;newTextBoxDiv3 . a f t e r ( ) . html( ’< l abe l>Food Group : </labe l >’ +’< input type=”text ” c l a s s=”food group ” name=”food group [ ’+ counter + ’]” id=”food group ’ +

counter + ’” value=”” > ’) ;

newTextBoxDiv . appendTo(”#TextBoxesGroup ”) ;newTextBoxDiv3 . appendTo(”#TextBoxesGroup ”) ;newTextBoxDiv1 . appendTo(”#TextBoxesGroup ”) ;newTextBoxDiv2 . appendTo(”#TextBoxesGroup ”) ;

document . getElementById (” ingred i ent measure ” + counter ) . readOnly=true ;document . getElementById (” food group ” + counter ) . readOnly=true ;

var id ;$ ( ’ . i ng r ed i en t s ’ ) . autocomplete ({minLength : 0 ,source : func t i on ( request , re sponse ) {id = th i s . element . context . a t t r i b u t e s [ name=”id ” ] . va lue ;

95

Page 107: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

// conso l e . l og ( id ) ;$ . a jax ( {ur l : ”<?php echo s i t e u r l ( ’ home cmanager/ sugges t ions ’ ) ; ?>”,data : request ,dataType : ” j son ” ,type : ”POST” ,suc c e s s : func t i on ( data ) {re sponse ( $ .map( data , func t i on (v , i ){i f ( v . measure != nu l l )data2 [ data2 . l ength ] = v . measure ;e l s e i f ( v . food name != nu l l )data2 [ data2 . l ength ] = v . food name ;e l s e i f ( v . energy != nu l l )data2 [ data2 . l ength ] = v . energy ;e l s e i f ( v . carbohydrate != nu l l )data2 [ data2 . l ength ] = v . carbohydrate ;e l s e i f ( v . p ro t e in != nu l l )data2 [ data2 . l ength ] = v . p ro t e in ;e l s e i f ( v . f a t != nu l l )data2 [ data2 . l ength ] = v . f a t ;e l s e i f ( v . food group != nu l l )data2 [ data2 . l ength ] = v . food group ;

re turn {l a b e l : v . food name} ;}) ) ;}}) ;} ,s e l e c t : func t i on ( event , u i ) {var num = id . subs t r i ng ( id . indexOf (” s ”) + 1 , id . l ength ) ;var measure = nu l l ;var food group = nu l l ;var c a l o r i e , carbohydrate , prote in , f a t ;f o r ( var i = 0 ; i < data2 . l ength ; i+=7){i f ( data2 [ i ] == ui . item . value ) {measure = data2 [ i + 1 ] ;c a l o r i e = data2 [ i + 2 ] ;carbohydrate = data2 [ i + 3 ] ;p ro t e in = data2 [ i + 4 ] ;f a t = data2 [ i + 5 ] ;food group = data2 [ i +6] ;}}// conso l e . l og ( c a l o r i e ) ;$( ’# ingred ient measure ’+num) . va l ( measure ) ;$( ’# food group ’+num) . va l ( food group ) ;/∗$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) + +c a l o r i e ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) + +carbohydrate ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) + +prote in ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) + +fa t ) ;∗/}}) ;counter++;}) ;

$(”#removeIngredientButton ”) . c l i c k ( func t i on ( ) {i f ( counter==1){a l e r t (”No more textbox to remove ”) ;re turn f a l s e ;}counter−−;

var r eques t = new XMLHttpRequest ( ) , u r l = ”<?php echo s i t e u r l ( ’ home cmanager/ ge t f a ’ ) ; ?>”,params = ” ing r ed i en t=”+($(”# ing r ed i e n t s”+counter ) . va l ( ) == ”” ? 0 : $(”# ing r ed i e n t s”+counter ) . va l ( ) ) ;

r eques t . onreadystatechange = func t i on ( ) {i f ( r eques t . readyState == 4 && reques t . s t a tu s == 200) {var temp = reques t . responseText . s p l i t ( ” , ” ) ;$(”#TextBoxDiv” + counter ) . remove ( ) ;$(”#TextBoxDiv3” + counter ) . remove ( ) ;$(”#TextBoxDiv1” + counter ) . remove ( ) ;$(”#TextBoxDiv2” + counter ) . remove ( ) ;

i f ( quant i ty [ counter ] != ”” && quant i ty [ counter ] != nu l l ) {$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) − (+temp [ 0 ] ∗ quant i ty [ counter ] ) ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) − (+temp [ 1 ] ∗ quant i ty [ counter ] ) ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) − (+temp [ 2 ] ∗ quant i ty [ counter ] ) ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) − (+temp [ 3 ] ∗ quant i ty [ counter ] ) ) ;}}}r eques t . open (”POST” , ur l , t rue ) ;r eques t . setRequestHeader (”Content−type ” , ” app l i c a t i on /x−www−form−ur lencoded ”) ;r eques t . send ( params ) ;}) ;}) ;

f unc t i on hea l thCondit ionsGuide l inesModal ( ) {$(”#hea l thCondit ionsGuide l inesModalDia log ”) . d i a l og ({autoOpen : f a l s e ,modal : true ,t i t l e : ’ Gu ide l ine s f o r Health Condit ions ’ ,width : ’ auto ’ ,he ight : ’ auto ’ ,buttons : {

96

Page 108: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

”Ok” : func t i on ( ) {$ ( t h i s ) . d i a l og (” c l o s e ”) ;}} ,}) . d i a l og ( ’ open ’ ) ;r e turn f a l s e ;}

f unc t i on va l i d a t e ( ) {var e r r o r s = ”<p s t y l e =’ c o l o r : red ; font−weight : bold ’>”;i f ( $(”#recipe name ”) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Recipe Name f i e l d i s r equ i r ed .<br>”;i f ( $(”# se rv ing sugg ”) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Serv ing S i z e f i e l d i s r equ i r ed .<br>”;i f ( $(”#prepara t i on procedure ”) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Procedure f i e l d i s r equ i r ed .<br>”;i f ( $(”# ing r ed i en t s 0 ”) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Ing r ed i en t s f i e l d i s r equ i r ed .<br>”;var f i l e = $ (” input [ name=’ u s e r f i l e ’ ] ” ) . va l ( ) ;i f ( f i l e != ””) {var f i l e t y p e s = [” g i f ” , ” jpg ” , ” jpeg ” , ”png ” ] ;var ext = f i l e . subs t r ( f i l e . l a s t IndexOf ( ” . ” ) + 1 , f i l e . l ength ) . 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 type i s i n v a l i d .<br>”;}

var i n g r ed i e n t s = new Array ( ) ;

$(”# ing r con t input [ type=’ text ’ ] ” ) . each ( func t i on ( ) {i f ( $ ( t h i s ) . a t t r (” id ”) . indexOf (” i n g r ed i e n t s ”) > −1 && $ ( t h i s ) . va l ( ) . tr im ( ) != ””) {var id = $ ( t h i s ) . a t t r (” id ”) . subs t r ( $ ( t h i s ) . a t t r (” id ”) . indexOf (” s ”) + 1 , $ ( t h i s ) . a t t r (” id ”) .

l ength ) ;var value = { i n g r ed i en t : $ ( t h i s ) . va l ( ) . tr im ( ) , foodgroup : $(”#food group”+id ) . va l ( ) . tr im ( ) } ;i f ( $(”# ing r ed i en t quan t i t y”+id ) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Quantity f i e l d i s r equ i r ed .<br>”;e l s evalue . quant i ty = $(”# ing r ed i en t quan t i t y”+id ) . va l ( ) . tr im ( ) ;

i f ( va lue . quant i ty != nu l l )i n g r ed i e n t s . push ( value ) ;}}) ;

var h ea l t h cond i t i on = $(”#hea l t h cond i t i on ”) . va l ( ) , i ;

f o r ( i = 0 ; i < i n g r e d i e n t s . l ength ; i++) {

var food group = ing r ed 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 ength ; j++)i f ( i n g r ed i e n t s [ i ] . foodgroup == food group )count += parseF loat ( i n g r ed i e n t s [ i ] . quant i ty ) ;

conso l e . l og ( count+”;”+ food group ) ;

i f ( h e a l t h cond i t i on == ”Diabetes ”) {i f ( ( food group === ”Vegetable ” | | food group === ”Frui t ”) && count > 4) {e r r o r s += ”You are only al lowed a maximum of 4 s e r v i ng s o f ”+food group+” da i l y .<br>”;} e l s e i f ( food group === ”Milk” && count > 3) {e r r o r s += ”You are only al lowed a maximum of 3 s e r v i ng s o f Milk da i l y .<br>”;} e l s e i f ( food group === ”Rice ” && count > 9) {e r r o r s += ”You are only al lowed a maximum of 9 s e r v i ng s o f Rice da i l y .<br>”;} e l s e i f ( food group === ”Meat” && count > 6) {e r r o r s += ”You are only al lowed a maximum of 6 s e r v i ng s o f Meat da i l y .<br>”;} e l s e i f ( food group === ”Meat” && count > 5) {e r r o r s += ”You are only al lowed a maximum of 5 s e r v i ng s o f Fat da i l y .<br>”;}} e l s e i f ( h ea l t h cond i t i on == ’ Hypertension ’ | | hea l t h cond i t i on == ’Kidney Stones ’ ) {i f ( ( food group === ”Vegetable ” | | food group === ”Frui t ”) && count > 5) {e r r o r s += ”You are only al lowed a maximum of 5 s e r v i ng s o f ”+food group+” da i l y .<br>”;} e l s e i f ( food group === ”Milk” && count > 5) {e r r o r s += ”You are only al lowed a maximum of 5 s e r v i ng s o f Milk da i l y .<br>”;} e l s e i f ( food group === ”Rice ” && count > 8) {e r r o r s += ”You are only al lowed a maximum of 8 s e r v i ng s o f Rice da i l y .<br>”;} e l s e i f ( food group === ”Meat” && count > 2) {e r r o r s += ”You are only al lowed a maximum of 2 s e r v i ng s o f Meat da i l y .<br>”;} e l s e i f ( food group === ”Meat” && count > 3) {e r r o r s += ”You are only al lowed a maximum of 3 s e r v i ng s o f Fat da 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 : red ; font−weight : bold ’></p>”) {$(”#addRecipeDialog ”) . prepend ( e r r o r s ) ;r e turn f a l s e ;}}</s c r i p t></head><body><div id=”hea l thCondit ionsGuide l inesModalDia log ” s t y l e=”d i sp l ay : none;”><center><table><tr><p>Below are the maximum da i l y s e r v i ng s f o r each food group f o r each hea l th cond i t i on :</tr><tr><th><h4>Food Group</th>

97

Page 109: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<th><h4>Diabetes</th><th><h4>Hypertension</th><th><h4>Kidney Stones</th></tr><tr><td>Vegetable<td>4<td>5<td>5</tr><tr><td>Frui t<td>4<td>5<td>5</tr><tr><td>Milk<td>3<td>5<td>5</tr><tr><td>Rice<td>9<td>8<td>8</tr><tr><td>Meat<td>6<td>2<td>2</tr><tr><td>Fat<td>5<td>3<td>3</tr></table></center></div>

<div id=”addRecipeDialog ” t i t l e =”Create Recipe ”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo 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

) ) { echo $ e r r o r d i s p l a y ; } ?></b></font><?php echo form open mult ipart ( ’ home cmanager/ add rec ipe save ’ , array ( ’ onsubmit ’=>’ r e turn

va l i d a t e ( ) ’ ) ) ; ?><center><table><tr><a h r e f=”#” onc l i c k=” j a v a s c r i p t : hea l thCondit ionsGuide l inesModal ( ) ;”>Guide l ine s f o r Health

Condit ions</a></tr><tr></tr><tr></tr><tr><td><l a b e l f o r=”hea l t h cond i t i on”>&nbsp ; Health Condit ion :</ labe l><td><input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Diabetes ” <?

php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (” Diabetes ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Diabetes<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Hypertension ” <?php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (” Hypertension ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Hypertension<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Kidney Stones ”<?php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (”Kidney Stones ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Kidney Stones<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”None” <?php i f( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (”None” , $ POST [” hea l t h cond i t i on ” ] ) ) ) {echo ” checked ” ;} ?>>None<br>

<!−−<td><s e l e c t id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on”><opt ion value=”Diabetes ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Diabetes ”) echo ” s e l e c t e d ”;?>>Diabetes</option><opt ion value=”Hypertension ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Hypertension ”) echo ” s e l e c t e d ”;?>>Hypertension</option><opt ion value=”Kidney Stones ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Kidney Stones ”) echo ” s e l e c t e d ”;?>>Kidney Stones</option><opt ion value=”None” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[” hea l t h cond i t i on ” ]

== ”None”) echo ” s e l e c t e d ”;?>>None</option></s e l e c t>−−></tr><tr><td><l a b e l f o r=”meal type”>&nbsp ; Meal Type:</ labe l><td><s e l e c t id=”meal type ” name=”meal type”><opt ion value=”Breakfast ” <?php i f ( i s s e t ($ POST [” meal type ” ] ) && $ POST[” meal type ” ] == ”

Breakfast ”) echo ” s e l e c t e d ”;?>>Breakfast</option><opt ion value=”Lunch” <?php i f ( i s s e t ($ POST [” meal type ” ] ) && $ POST[” meal type ” ] == ”Lunch”)

echo ” s e l e c t e d ”;?>>Lunch</option><opt ion value=”Dinner” <?php i f ( i s s e t ($ POST [” meal type ” ] ) && $ POST[” meal type ” ] == ”Dinner

”) echo ” s e l e c t e d ”;?>>Dinner</option><opt ion value=”Snack” <?php i f ( i s s e t ($ POST [” meal type ” ] ) && $ POST[” meal type ” ] == ”Snack ”)

echo ” s e l e c t e d ”;?>>Snack</option></s e l e c t></tr><tr><td><l a b e l f o r=”u s e r f i l e ”>&nbsp ; Recipe Image:</ labe l><td><input name=”u s e r f i l e ” type=” f i l e ” s i z e =”20” ></tr>

98

Page 110: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<tr><td><l a b e l f o r=”rec ipe name”>&nbsp ; Recipe Name:</ labe l><td><input id=”rec ipe name ” name=”rec ipe name ” type=”text ” value=”<?php echo s e t v a l u e ( ’

recipe name ’ ) ; ?>” ></tr><tr><td><l a b e l f o r=”se rv ing sugg”>&nbsp ; Serv ing S i z e :</ labe l><td><input id=”se rv ing sugg ” name=”se rv ing sugg ” type=”text ” value=”<?php echo s e t v a l u e ( ’

s e rv ing sugg ’ ) ; ?>” s i z e =”2” ></tr><tr><td><l a b e l f o r=” i n g r ed i e n t s”>&nbsp ; I ng r ed i en t s :</ labe l><td><button id=”addIngredientButton ” name=”addIngredientButton ” value=”” type=”button” value=”Add

”><span c l a s s=”ui−i con ui−icon−p lu s th i ck”></span></button><button id=”removeIngredientButton ” name=”removeIngredientButton ” value=”Remove” type=”button

”><span c l a s s=”ui−i con ui−icon−minusthick”></span></button><br>I ng r ed i en t : &nbsp;&nbsp;&nbsp;< input id=”ing r ed i en t s 0 ” name=”i ng r ed i e n t s [ 0 ] ” c l a s s=”

i n g r ed i e n t s ” type=”text ” value=”<?php echo s e t v a l u e ( ’ i ng r ed i en t s ’ ) ; ?>” ><br>Food Group : <input id=”food group0 ” name=”food group [ 0 ] ” c l a s s=”food group ” type=”text ” value

=”<?php echo s e t v a l u e ( ’ food group ’ ) ; ?>” readonly ><br>Measure ( g ) : <input id=”ingred i ent measure0 ” name=”ingred i ent measure [ 0 ] ” c l a s s=”measure” type

=”text ” value=”<?php echo s e t v a l u e ( ’ ingred ient measure ’ ) ; ?>” readonly><br>Quantity : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;< input id=”ing r ed i en t quan t i t y0 ” name=”

ing r ed i en t quan t i t y [ 0 ] ” type=”text ” value=”<?php echo s e t v a l u e ( ’ i ng r ed i en t quant i t y ’ ) ;?>” onchange=”update (0 ) ” >

<br><div id=’TextBoxesGroup ’></div></tr><tr><td><l a b e l f o r=”prepara t i on procedure”>&nbsp ; Procedure :</ labe l><td><t ex ta r ea id=”prepara t i on procedure ” name=”prepara t i on procedure ” type=”text”><?php echo

s e t v a l u e ( ’ preparat ion procedure ’ ) ; ?></textarea></tr><!−−<tr><td><l a b e l f o r=”t o t a l quan t i t y”>&nbsp ; Total Quantity :</ labe l><td><input id=”t o t a l quan t i t y ” name=”t o t a l quan t i t y ” type=”text ” value=”<?php echo s e t v a l u e

( ’ t o t a l quan t i t y ’ ) ; ?>”></tr>−−><tr><td><l a b e l f o r=” c a l o r i e s”>&nbsp ; Total Ca l o r i e s ( Kcal ) :</ labe l><td><input id=”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 ” type=”text ” value=”<?php echo

s e t v a l u e ( ’ c a l o r i e s ’ ) ; ?>” readonly></tr><tr><td><l a b e l f o r=”carbohydrate”>&nbsp ; Total Carbohydrates ( g ) :</ labe l><td><input id=”carbohydrate ” name=”carbohydrate ” type=”text ” value=”<?php echo s e t v a l u e ( ’

carbohydrate ’ ) ; ?>” readonly></tr><tr><td><l a b e l f o r=”pro t e in”>&nbsp ; Total Prote in ( g ) :</ labe l><td><input id=”pro t e in ” name=”pro t e in ” type=”text ” value=”<?php echo s e t v a l u e ( ’ prote in ’ ) ;

?>” readonly></tr><tr><td><l a b e l f o r=”f a t”>&nbsp ; Total Fat ( g ) :</ labe l><td><input id=”f a t ” name=”f a t ” type=”text ” value=”<?php echo s e t v a l u e ( ’ fat ’ ) ; ?>” readonly></tr>

<tr><td><button id=”addRecipeButton” type=”submit” name=”submit” value=”submit”>Create Recipe</

button><td><button id=”addRecipeBackButton” type=”button” name=”addRecipeBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Back</button><button id=”addRecipeHomeButton” type=”button” name=”addRecipeHomeButton” value=”Home” onc l i c k

=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>var quant i ty ;$ ( func t i on ( ) {var data2 = [ ] ;var index = 0 ;

$ ( ”#addRecipeButton , #addRecipeBackButton , #addRecipeHomeButton” ) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets

99

Page 111: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;}}) ;$ ( ”#addRecipeDialog ” ) . d i a l og ({autoOpen : true ,width : 600 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;

var id ;$ ( ’ . i ng r ed i en t s ’ ) . autocomplete ({minLength : 0 ,source : func t i on ( request , re sponse ) {id = th i s . element . context . a t t r i b u t e s [ name=”id ” ] . va lue ;// conso l e . l og ( id ) ;$ . a jax ( {ur l : ”<?php echo s i t e u r l ( ’ home user / sugges t i ons ’ ) ; ?>”,data : request ,dataType : ” j son ” ,type : ”POST” ,suc c e s s : func t i on ( data ) {// conso l e . l og (JSON. s t r i n g i f y ( data ) ) ;re sponse ( $ .map( data , func t i on (v , i ){i f ( v . measure != nu l l )data2 [ data2 . l ength ] = v . measure ;e l s e i f ( v . food name != nu l l )data2 [ data2 . l ength ] = v . food name ;e l s e i f ( v . energy != nu l l )data2 [ data2 . l ength ] = v . energy ;e l s e i f ( v . carbohydrate != nu l l )data2 [ data2 . l ength ] = v . carbohydrate ;e l s e i f ( v . p ro t e in != nu l l )data2 [ data2 . l ength ] = v . p ro t e in ;e l s e i f ( v . f a t != nu l l )data2 [ data2 . l ength ] = v . f a t ;e l s e i f ( v . food group != nu l l )data2 [ data2 . l ength ] = v . food group ;

re turn {l a b e l : v . food name} ;}) ) ;}}) ;} ,s e l e c t : func t i on ( event , u i ) {var num = id . subs t r i ng ( id . indexOf (” s ”) + 1 , id . l ength ) ;var measure = nu l l ;var food group = nu l l ;var c a l o r i e , carbohydrate , prote in , f a t ;f o r ( var i = 0 ; i < data2 . l ength ; i+=7){i f ( data2 [ i ] == ui . item . value ) {measure = data2 [ i + 1 ] ;c a l o r i e = data2 [ i + 2 ] ;carbohydrate = data2 [ i + 3 ] ;p ro t e in = data2 [ i + 4 ] ;f a t = data2 [ i + 5 ] ;food group = data2 [ i +6] ;}}// conso l e . l og ( c a l o r i e ) ;$( ’# ingred ient measure ’+num) . va l ( measure ) ;$( ’# food group ’+num) . va l ( food group ) ;/∗$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) + +c a l o r i e ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) + +carbohydrate ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) + +prote in ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) + +fa t ) ;∗/}/∗ f o cus : func t i on ( event , u i ) {$ ( ” . i n g r ed i e n t s ” ) . va l ( u i . item . l a b e l ) ;} ,s e l e c t : func t i on ( event , u i ) {}∗/}) ;}) ;

f unc t i on update ( id ) {var reques t = new XMLHttpRequest ( ) , u r l = ”<?php echo s i t e u r l ( ’ home user / ge t f a ’ ) ; ?>”,

params = ” ing r ed i en t=”+$(”# ing r ed i e n t s”+id ) . va l ( ) ;

100

Page 112: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

r eques t . onreadystatechange = func t i on ( ) {i f ( r eques t . readyState == 4 && reques t . s t a tu s == 200) {var temp = reques t . responseText . s p l i t ( ” , ” ) , i ;

$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) − (+temp [ 0 ] ∗ quant i ty [ id ] ) ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) − (+temp [ 1 ] ∗ quant i ty [ id ] ) ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) − (+temp [ 2 ] ∗ quant i ty [ id ] ) ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) − (+temp [ 3 ] ∗ quant i ty [ id ] ) ) ;

f o r ( i = 0 ; i < temp . l ength ; i++)temp [ i ] = +temp [ i ] ∗ $(”# ing r ed i en t quan t i t y”+id ) . va l ( ) ;

$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) + temp [ 0 ] ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) + temp [ 1 ] ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) + temp [ 2 ] ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) + temp [ 3 ] ) ;

quant i ty [ id ] = $(”# ing r ed i en t quan t i t y”+id ) . va l ( ) ;}}r eques t . open (”POST” , ur l , t rue ) ;r eques t . setRequestHeader (”Content−type ” , ” app l i c a t i on /x−www−form−ur lencoded ”) ;r eques t . send ( params ) ;}

$ ( document ) . ready ( func t i on ( ) {var counter = 1 ;var data2 = [ ] ;quant i ty = new Array ( ) ;

quant i ty [ 0 ] = $(”# ing r ed i en t quan t i t y0 ”) . va l ( ) == ”” ? 0 : $(”# ing r ed i en t quan t i t y0 ”) . va l ( ) ;

$(”#addIngredientButton ”) . c l i c k ( func t i on ( ) {

/∗ i f ( counter >10){a l e r t (”Only 10 textboxes a l low ”) ;re turn f a l s e ;} ∗/

quant i ty [ counter ] = 0 ;

var newTextBoxDiv = $ ( document . createElement ( ’ div ’ ) ) . a t t r (” id ” , ’TextBoxDiv ’ + counter ) ;newTextBoxDiv . a f t e r ( ) . html( ’<br><l abe l>I ng r ed i en t : &nbsp;&nbsp;&nbsp;</ labe l >’ +’< input type=”text ” c l a s s=” i n g r ed i e n t s ” name=”i ng r ed i e n t s [ ’+ counter + ’]” id=”ing r ed i en t s ’ +

counter + ’” value=”” > ’) ;

var newTextBoxDiv1= $ ( document . createElement ( ’ div ’ ) ) . a t t r (” id ” , ’ TextBoxDiv1 ’ + counter ) ;newTextBoxDiv1 . a f t e r ( ) . html( ’< l abe l>Measure ( g ) : </labe l >’ +’< input type=”text ” c l a s s=”measure” name=”ingred i ent measure [ ’+ counter + ’]” id=”

ingred ient measure ’ + counter + ’” value=”” > ’) ;

var newTextBoxDiv2= $ ( document . createElement ( ’ div ’ ) ) . a t t r (” id ” , ’ TextBoxDiv2 ’ + counter ) ;newTextBoxDiv2 . a f t e r ( ) . html( ’< l abe l>Quantity : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</ labe l >’ +’< input type=”text ” name=”ing r ed i en t quan t i t y [ ’+ counter + ’]” id=”ing r ed i en t quant i t y ’ + counter

+ ’” value=”” onchange=”update ( ’+ counter + ’)”> ’) ;

var newTextBoxDiv3= $ ( document . createElement ( ’ div ’ ) ) . a t t r (” id ” , ’ TextBoxDiv3 ’ + counter ) ;newTextBoxDiv3 . a f t e r ( ) . html( ’< l abe l>Food Group : </labe l >’ +’< input type=”text ” c l a s s=”food group ” name=”food group [ ’+ counter + ’]” id=”food group ’ +

counter + ’” value=”” > ’) ;

newTextBoxDiv . appendTo(”#TextBoxesGroup ”) ;newTextBoxDiv3 . appendTo(”#TextBoxesGroup ”) ;newTextBoxDiv1 . appendTo(”#TextBoxesGroup ”) ;newTextBoxDiv2 . appendTo(”#TextBoxesGroup ”) ;

document . getElementById (” ingred i ent measure ” + counter ) . readOnly=true ;document . getElementById (” food group ” + counter ) . readOnly=true ;

var id ;$ ( ’ . i ng r ed i en t s ’ ) . autocomplete ({minLength : 0 ,source : func t i on ( request , re sponse ) {id = th i s . element . context . a t t r i b u t e s [ name=”id ” ] . va lue ;// conso l e . l og ( id ) ;$ . a jax ( {ur l : ”<?php echo s i t e u r l ( ’ home user / sugges t i ons ’ ) ; ?>”,data : request ,dataType : ” j son ” ,type : ”POST” ,suc c e s s : func t i on ( data ) {re sponse ( $ .map( data , func t i on (v , i ){i f ( v . measure != nu l l )data2 [ data2 . l ength ] = v . measure ;e l s e i f ( v . food name != nu l l )data2 [ data2 . l ength ] = v . food name ;e l s e i f ( v . energy != nu l l )data2 [ data2 . l ength ] = v . energy ;e l s e i f ( v . carbohydrate != nu l l )data2 [ data2 . l ength ] = v . carbohydrate ;e l s e i f ( v . p ro t e in != nu l l )data2 [ data2 . l ength ] = v . p ro t e in ;e l s e i f ( v . f a t != nu l l )data2 [ data2 . l ength ] = v . f a t ;e l s e i f ( v . food group != nu l l )data2 [ data2 . l ength ] = v . food group ;

re turn {l a b e l : v . food name

101

Page 113: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

} ;}) ) ;}}) ;} ,s e l e c t : func t i on ( event , u i ) {var num = id . subs t r i ng ( id . indexOf (” s ”) + 1 , id . l ength ) ;var measure = nu l l ;var food group = nu l l ;var c a l o r i e , carbohydrate , prote in , f a t ;f o r ( var i = 0 ; i < data2 . l ength ; i+=7){i f ( data2 [ i ] == ui . item . value ) {measure = data2 [ i + 1 ] ;c a l o r i e = data2 [ i + 2 ] ;carbohydrate = data2 [ i + 3 ] ;p ro t e in = data2 [ i + 4 ] ;f a t = data2 [ i + 5 ] ;food group = data2 [ i +6] ;}}// conso l e . l og ( c a l o r i e ) ;$( ’# ingred ient measure ’+num) . va l ( measure ) ;$( ’# food group ’+num) . va l ( food group ) ;/∗$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) + +c a l o r i e ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) + +carbohydrate ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) + +prote in ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) + +fa t ) ;∗/}}) ;counter++;}) ;

$(”#removeIngredientButton ”) . c l i c k ( func t i on ( ) {i f ( counter==1){a l e r t (”No more textbox to remove ”) ;re turn f a l s e ;}counter−−;

var r eques t = new XMLHttpRequest ( ) , u r l = ”<?php echo s i t e u r l ( ’ home user / ge t f a ’ ) ; ?>”,params = ” ing r ed i en t=”+($(”# ing r ed i e n t s”+counter ) . va l ( ) == ”” ? 0 : $(”# ing r ed i e n t s”+counter ) . va l ( ) ) ;

r eques t . onreadystatechange = func t i on ( ) {i f ( r eques t . readyState == 4 && reques t . s t a tu s == 200) {var temp = reques t . responseText . s p l i t ( ” , ” ) ;$(”#TextBoxDiv” + counter ) . remove ( ) ;$(”#TextBoxDiv3” + counter ) . remove ( ) ;$(”#TextBoxDiv1” + counter ) . remove ( ) ;$(”#TextBoxDiv2” + counter ) . remove ( ) ;

i f ( quant i ty [ counter ] != ”” && quant i ty [ counter ] != nu l l ) {$( ’# c a l o r i e s ’ ) . va l (+$( ’# c a l o r i e s ’ ) . va l ( ) − (+temp [ 0 ] ∗ quant i ty [ counter ] ) ) ;$( ’# carbohydrate ’ ) . va l (+$( ’# carbohydrate ’ ) . va l ( ) − (+temp [ 1 ] ∗ quant i ty [ counter ] ) ) ;$( ’# prote in ’ ) . va l (+$( ’# prote in ’ ) . va l ( ) − (+temp [ 2 ] ∗ quant i ty [ counter ] ) ) ;$( ’# fat ’ ) . va l (+$( ’# fat ’ ) . va l ( ) − (+temp [ 3 ] ∗ quant i ty [ counter ] ) ) ;}}}r eques t . open (”POST” , ur l , t rue ) ;r eques t . setRequestHeader (”Content−type ” , ” app l i c a t i on /x−www−form−ur lencoded ”) ;r eques t . send ( params ) ;}) ;}) ;

f unc t i on hea l thCondit ionsGuide l inesModal ( ) {$(”#hea l thCondit ionsGuide l inesModalDia log ”) . d i a l og ({autoOpen : f a l s e ,modal : true ,t i t l e : ’ Gu ide l ine s f o r Health Condit ions ’ ,width : ’ auto ’ ,he ight : ’ auto ’ ,buttons : {”Ok” : func t i on ( ) {$ ( t h i s ) . d i a l og (” c l o s e ”) ;}} ,}) . d i a l og ( ’ open ’ ) ;r e turn f a l s e ;}

f unc t i on va l i d a t e ( ) {var e r r o r s = ”<p s t y l e =’ c o l o r : red ; font−weight : bold ’>”;i f ( $(”#recipe name ”) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Recipe Name f i e l d i s r equ i r ed .<br>”;i f ( $(”# se rv ing sugg ”) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Serv ing S i z e f i e l d i s r equ i r ed .<br>”;i f ( $(”#prepara t i on procedure ”) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Procedure f i e l d i s r equ i r ed .<br>”;i f ( $(”# ing r ed i en t s 0 ”) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Ing r ed i en t s f i e l d i s r equ i r ed .<br>”;var f i l e = $ (” input [ name=’ u s e r f i l e ’ ] ” ) . va l ( ) ;i f ( f i l e != ””) {var f i l e t y p e s = [” g i f ” , ” jpg ” , ” jpeg ” , ”png ” ] ;var ext = f i l e . subs t r ( f i l e . l a s t IndexOf ( ” . ” ) + 1 , f i l e . l ength ) . 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 type i s i n v a l i d .<br>”;}

102

Page 114: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

var i n g r ed i e n t s = new Array ( ) ;

$(”# ing r con t input [ type=’ text ’ ] ” ) . each ( func t i on ( ) {i f ( $ ( t h i s ) . a t t r (” id ”) . indexOf (” i n g r ed i e n t s ”) > −1 && $ ( t h i s ) . va l ( ) . tr im ( ) != ””) {var id = $ ( t h i s ) . a t t r (” id ”) . subs t r ( $ ( t h i s ) . a t t r (” id ”) . indexOf (” s ”) + 1 , $ ( t h i s ) . a t t r (” id ”) .

l ength ) ;var value = { i n g r ed i en t : $ ( t h i s ) . va l ( ) . tr im ( ) , foodgroup : $(”#food group”+id ) . va l ( ) . tr im ( ) } ;i f ( $(”# ing r ed i en t quan t i t y”+id ) . va l ( ) . tr im ( ) == ””)e r r o r s += ”The Quantity f i e l d i s r equ i r ed .<br>”;e l s evalue . quant i ty = $(”# ing r ed i en t quan t i t y”+id ) . va l ( ) . tr im ( ) ;

i f ( va lue . quant i ty != nu l l )i n g r ed i e n t s . push ( value ) ;}}) ;

var h ea l t h cond i t i on = $(”#hea l t h cond i t i on ”) . va l ( ) , i ;

f o r ( i = 0 ; i < i n g r e d i e n t s . l ength ; i++) {

var food group = ing r ed 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 ength ; j++)i f ( i n g r ed i e n t s [ i ] . foodgroup == food group )count += parseF loat ( i n g r ed i e n t s [ i ] . quant i ty ) ;

conso l e . l og ( count+”;”+ food group ) ;

i f ( h e a l t h cond i t i on == ”Diabetes ”) {i f ( ( food group === ”Vegetable ” | | food group === ”Frui t ”) && count > 4) {e r r o r s += ”You are only al lowed a maximum of 4 s e r v i ng s o f ”+food group+” da i l y .<br>”;} e l s e i f ( food group === ”Milk” && count > 3) {e r r o r s += ”You are only al lowed a maximum of 3 s e r v i ng s o f Milk da i l y .<br>”;} e l s e i f ( food group === ”Rice ” && count > 9) {e r r o r s += ”You are only al lowed a maximum of 9 s e r v i ng s o f Rice da i l y .<br>”;} e l s e i f ( food group === ”Meat” && count > 6) {e r r o r s += ”You are only al lowed a maximum of 6 s e r v i ng s o f Meat da i l y .<br>”;} e l s e i f ( food group === ”Meat” && count > 5) {e r r o r s += ”You are only al lowed a maximum of 5 s e r v i ng s o f Fat da i l y .<br>”;}} e l s e i f ( h ea l t h cond i t i on == ’ Hypertension ’ | | hea l t h cond i t i on == ’Kidney Stones ’ ) {i f ( ( food group === ”Vegetable ” | | food group === ”Frui t ”) && count > 5) {e r r o r s += ”You are only al lowed a maximum of 5 s e r v i ng s o f ”+food group+” da i l y .<br>”;} e l s e i f ( food group === ”Milk” && count > 5) {e r r o r s += ”You are only al lowed a maximum of 5 s e r v i ng s o f Milk da i l y .<br>”;} e l s e i f ( food group === ”Rice ” && count > 8) {e r r o r s += ”You are only al lowed a maximum of 8 s e r v i ng s o f Rice da i l y .<br>”;} e l s e i f ( food group === ”Meat” && count > 2) {e r r o r s += ”You are only al lowed a maximum of 2 s e r v i ng s o f Meat da i l y .<br>”;} e l s e i f ( food group === ”Meat” && count > 3) {e r r o r s += ”You are only al lowed a maximum of 3 s e r v i ng s o f Fat da 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 : red ; font−weight : bold ’></p>”) {$(”#addRecipeDialog ”) . prepend ( e r r o r s ) ;r e turn f a l s e ;}}</s c r i p t></head><body><div id=”hea l thCondit ionsGuide l inesModalDia log ” s t y l e=”d i sp l ay : none;”><center><table><tr><p>Below are the maximum da i l y s e r v i ng s f o r each food group f o r each hea l th cond i t i on :</tr><tr><th><h4>Food Group</th><th><h4>Diabetes</th><th><h4>Hypertension</th><th><h4>Kidney Stones</th></tr><tr><td>Vegetable<td>4<td>5<td>5</tr><tr><td>Frui t<td>4<td>5<td>5</tr><tr><td>Milk<td>3<td>5<td>5</tr><tr><td>Rice<td>9

103

Page 115: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<td>8<td>8</tr><tr><td>Meat<td>6<td>2<td>2</tr><tr><td>Fat<td>5<td>3<td>3</tr></table></center></div>

<div id=”addRecipeDialog ” t i t l e =”Create Recipe ”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo 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

) ) { echo $ e r r o r d i s p l a y ; } ?></b></font><?php echo form open mult ipart ( ’ home user / add rec ipe save ’ , array ( ’ onsubmit ’=>’ r e turn va l i d a t e

( ) ’ ) ) ; ?><center><table><tr><a h r e f=”#” onc l i c k=” j a v a s c r i p t : hea l thCondit ionsGuide l inesModal ( ) ;”>Guide l ine s f o r Health

Condit ions</a></tr><tr></tr><tr></tr><tr><td><l a b e l f o r=”hea l t h cond i t i on”>&nbsp ; Health Condit ion :</ labe l><td><input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Diabetes ” <?

php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (” Diabetes ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Diabetes<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Hypertension ” <?php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (” Hypertension ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Hypertension<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”Kidney Stones ”<?php i f ( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (”Kidney Stones ” , $ POST [”hea l t h cond i t i on ” ] ) ) ) { echo ” checked ” ;} ?>>Kidney Stones<br>

<input type=”checkbox” id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on [ ] ” value=”None” <?php i f( ( ! empty ($ POST [” hea l t h cond i t i on ” ] ) && in a r r ay (”None” , $ POST [” hea l t h cond i t i on ” ] ) ) ) {echo ” checked ” ;} ?>>None<br>

<!−−<td><s e l e c t id=”hea l t h cond i t i on ” name=”hea l t h cond i t i on”><opt ion value=”Diabetes ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Diabetes ”) echo ” s e l e c t e d ”;?>>Diabetes</option><opt ion value=”Hypertension ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Hypertension ”) echo ” s e l e c t e d ”;?>>Hypertension</option><opt ion value=”Kidney Stones ” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[”

hea l t h cond i t i on ” ] == ”Kidney Stones ”) echo ” s e l e c t e d ”;?>>Kidney Stones</option><opt ion value=”None” <?php i f ( i s s e t ($ POST [” hea l t h cond i t i on ” ] ) && $ POST[” hea l t h cond i t i on ” ]

== ”None”) echo ” s e l e c t e d ”;?>>None</option></s e l e c t>−−></tr><tr><td><l a b e l f o r=”meal type”>&nbsp ; Meal Type:</ labe l><td><s e l e c t id=”meal type ” name=”meal type”><opt ion value=”Breakfast ” <?php i f ( i s s e t ($ POST [” meal type ” ] ) && $ POST[” meal type ” ] == ”

Breakfast ”) echo ” s e l e c t e d ”;?>>Breakfast</option><opt ion value=”Lunch” <?php i f ( i s s e t ($ POST [” meal type ” ] ) && $ POST[” meal type ” ] == ”Lunch”)

echo ” s e l e c t e d ”;?>>Lunch</option><opt ion value=”Dinner” <?php i f ( i s s e t ($ POST [” meal type ” ] ) && $ POST[” meal type ” ] == ”Dinner

”) echo ” s e l e c t e d ”;?>>Dinner</option><opt ion value=”Snack” <?php i f ( i s s e t ($ POST [” meal type ” ] ) && $ POST[” meal type ” ] == ”Snack ”)

echo ” s e l e c t e d ”;?>>Snack</option></s e l e c t></tr><tr><td><l a b e l f o r=”u s e r f i l e ”>&nbsp ; Recipe Image:</ labe l><td><input name=”u s e r f i l e ” type=” f i l e ” s i z e =”20” ></tr><tr><td><l a b e l f o r=”rec ipe name”>&nbsp ; Recipe Name:</ labe l><td><input id=”rec ipe name ” name=”rec ipe name ” type=”text ” value=”<?php echo s e t v a l u e ( ’

recipe name ’ ) ; ?>” ></tr><tr><td><l a b e l f o r=”se rv ing sugg”>&nbsp ; Serv ing S i z e :</ labe l><td><input id=”se rv ing sugg ” name=”se rv ing sugg ” type=”number” value=”<?php echo s e t v a l u e ( ’

s e rv ing sugg ’ ) ; ?>” s i z e =”2” min=”1” ></tr><tr><td><l a b e l f o r=” i n g r ed i e n t s”>&nbsp ; I ng r ed i en t s :</ labe l><td id=”ing r con t”><button id=”addIngredientButton ” name=”addIngredientButton ” value=”” type=”button” value=”Add

”><span c l a s s=”ui−i con ui−icon−p lu s th i ck”></span></button><button id=”removeIngredientButton ” name=”removeIngredientButton ” value=”Remove” type=”button

”><span c l a s s=”ui−i con ui−icon−minusthick”></span></button> <br>I ng r ed i en t : &nbsp;&nbsp;&nbsp;< input id=”ing r ed i en t s 0 ” name=”i ng r ed i e n t s [ 0 ] ” c l a s s=”

i n g r ed i e n t s ” type=”text ” value=”<?php echo s e t v a l u e ( ’ i ng r ed i en t s ’ ) ; ?>” ><br>Food Group : <input id=”food group0 ” name=”food group [ 0 ] ” c l a s s=”food group ” type=”text ” value

=”<?php echo s e t v a l u e ( ’ food group ’ ) ; ?>” readonly ><br>Measure ( g ) : <input id=”ingred i ent measure0 ” name=”ingred i ent measure [ 0 ] ” c l a s s=”measure” type

=”text ” value=”<?php echo s e t v a l u e ( ’ ingred ient measure ’ ) ; ?>” readonly><br>Quantity : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;< input id=”ing r ed i en t quan t i t y0 ” name=”

ing r ed i en t quan t i t y [ 0 ] ” type=”text ” value=”<?php echo s e t v a l u e ( ’ i ng r ed i en t quant i t y ’ ) ;?>” onchange=”update (0 ) ” >

104

Page 116: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<br><div id=’TextBoxesGroup ’></div></tr><tr><td><l a b e l f o r=”prepara t i on procedure”>&nbsp ; Procedure :</ labe l><td><t ex ta r ea id=”prepara t i on procedure ” name=”prepara t i on procedure ” type=”text”><?php echo

s e t v a l u e ( ’ preparat ion procedure ’ ) ; ?></textarea></tr><!−−<tr><td><l a b e l f o r=”t o t a l quan t i t y”>&nbsp ; Total Quantity :</ labe l><td><input id=”t o t a l quan t i t y ” name=”t o t a l quan t i t y ” type=”text ” value=”<?php echo s e t v a l u e

( ’ t o t a l quan t i t y ’ ) ; ?>”></tr>−−><tr><td><l a b e l f o r=” c a l o r i e s”>&nbsp ; Total Ca l o r i e s ( Kcal ) :</ labe l><td><input id=”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 ” type=”text ” value=”<?php echo

s e t v a l u e ( ’ c a l o r i e s ’ ) ; ?>” readonly></tr><tr><td><l a b e l f o r=”carbohydrate”>&nbsp ; Total Carbohydrates ( g ) :</ labe l><td><input id=”carbohydrate ” name=”carbohydrate ” type=”text ” value=”<?php echo s e t v a l u e ( ’

carbohydrate ’ ) ; ?>” readonly></tr><tr><td><l a b e l f o r=”pro t e in”>&nbsp ; Total Prote in ( g ) :</ labe l><td><input id=”pro t e in ” name=”pro t e in ” type=”text ” value=”<?php echo s e t v a l u e ( ’ prote in ’ ) ;

?>” readonly></tr><tr><td><l a b e l f o r=”f a t”>&nbsp ; Total Fat ( g ) :</ labe l><td><input id=”f a t ” name=”f a t ” type=”text ” value=”<?php echo s e t v a l u e ( ’ fat ’ ) ; ?>” readonly></tr>

<tr><td><button id=”addRecipeButton” type=”submit” name=”submit” value=”submit”>Create Recipe</

button><td><button id=”addRecipeBackButton” type=”button” name=”addRecipeBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”addRecipeHomeButton” type=”button” name=”addRecipeHomeButton” value=”Back” onc l i c k

=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#addUserButton , #addUserBackButton , #addUserHomeButton ”) . button ( ) ;$ ( ”#userTypeRadioButtonSet , #genderRadioButtonSet ” ) . buttonset ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#b i r thdate ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# birthdate ’ ) . v a l i d ( ) ;i f ( $( ’# birthdate ’ ) . va 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 echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”#b i r t h d a t e v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

b i r t h d a t e r e qu i r e d e r r o r . png ’ ) ” }) ;}}}) ;$ ( ”#addUserDialog ” ) . d i a l og ({autoOpen : true ,

105

Page 117: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#username ”) . keyup ( func t i on ( ) {i f ( $(”#username ”) . va l ( ) . l ength >= 4) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home admin/ check use r ” ,data : ”name=”+$(”#username ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images / c o r r e c t

. png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

u s e rname ex i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e i f ( $(”#username ”) . va l ( ) . l ength < 4) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

use rname l ength e r ro r . png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”#password ”) . keyup ( func t i on ( ) {i f ( $(”#conf i rm password ”) . va l ( ) . l ength >= 8) {i f ( $(”#conf i rm password ”) . va l ( ) !=$(”#password ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}

e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}e l s e i f ( $(”#password ”) . va l ( ) . l ength < 8) {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

pa s sword l eng th e r ro r . png ’ ) ” }) ;}e l s e {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” })}}) ;

$(”#conf i rm password ”) . keyup ( func t i on ( ) {i f ( $(”#password ”) . va l ( ) . l ength >=8) {i f ( $(”#conf i rm password ”) . va l ( ) !=$(”#password ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}}) ;

$(”#ema i l addre s s ”) . keyup ( func t i on ( ) {var emai l = $(”#ema i l addre s s ”) . va l ( ) ;i f ( emai l != 0) {i f ( i sVal idEmai lAddress ( emai l ) ) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home admin/ check emai l ” ,data : ” emai l=”+$(”#ema i l addre s s ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;emai l con=true ;r e g i s t e r s how ( ) ;}

106

Page 118: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l e x i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l i n v a l i d e r r o r . png ’ ) ” }) ;}}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”# f i r s t name ”) . keyup ( func t i on ( ) {i f ( $( ’# f i r s t name ’ ) . va l ( ) != ’ ’ ) {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

f i r s t n ame r e q u i r e d e r r o r . png ’ ) ” }) ;}}) ;

$(”#last name ”) . keyup ( func t i on ( ) {i f ( $( ’# last name ’ ) . va l ( ) != ’ ’ ) {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

l a s t n ame r e qu i r e d e r r o r . png ’ ) ” }) ;}}) ;}) ;

f unc t i on isVal idEmai lAddress ( emailAddress ) {var pattern = new RegExp (/ˆ ( ( ” [\w−\s ]+”) | ( [ \w− ]+(? :\ . [\w−]+)∗) | ( ” [ \w−\s ]+”) ( [\w− ]+(? :\ . [\w−]+)

∗) ) (@( ( ? : [ \w−]+\.)∗\w[\w− ]{0 ,66}) \ . ( [ 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 ) ;

r e turn pattern . t e s t ( emailAddress ) ;}

</s c r i p t></head><body><div id=”addUserDialog ” t i t l e =”Add User”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open ( ’ home admin/ save ’ , array ( ’ username ’ => ’myform ’ ) ) ; ?><center><table><tr></tr><tr></tr><tr><td><l a b e l f o r=”f i r s t name”>&nbsp ; F i r s t Name:</ labe l><td><input id=”f i r s t name ” name=”f i r s t name ” type=”text ” value=”<?php echo s e t v a l u e ( ’

f i r s t name ’ ) ; ?>”><span id=” f i r s t n ame v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”middle name”>&nbsp ; Middle Name:</ labe l><td><input id=”middle name” name=”middle name” type=”text ” value=”<?php echo s e t v a l u e ( ’

middle name ’ ) ; ?>”>(Optional )</tr><tr><td><l a b e l f o r=”last name”>&nbsp ; Last Name:</ labe l><td><input id=”last name ” name=”last name ” type=”text ” value=”<?php echo s e t v a l u e ( ’ last name

’ ) ; ?>”><span id=”l a s tname ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”b i r thdate”>&nbsp ; Birthdate :</ labe l><td><input id=”b i r thdate ” name=”b i r thdate ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value=”<?

php echo s e t v a l u e ( ’ b i r thdate ’ ) ; ?>” readonly=”readonly”><a h r e f=”#bi r thdate ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><span id=”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></tr><tr><td><l a b e l f o r=”gender”>&nbsp ; Gender:</ labe l><td><div id=”genderRadioButtonSet”><input type=”rad io ” id=”genderMale” name=”genderRadio ” value=”Male” <?php echo s e t r a d i o ( ’

genderRadio ’ , ’Male ’ , TRUE) ; ?> ><l a b e l f o r=”genderMale”>Male</labe l><input type=”rad io ” id=”genderFemale” name=”genderRadio ” value=”Female” <?php echo s e t r a d i o ( ’

genderRadio ’ , ’ Female ’ ) ; ?>>< l a b e l f o r=”genderFemale”>Female</labe l></div></tr><tr><td><l a b e l f o r=”use r type”>&nbsp ; User Type:</ labe l><td><div id=”userTypeRadioButtonSet”><input type=”rad io ” id=”userTypeAdministrator ” name=”userTypeRadio” value=”Administrator ” <?

php echo s e t r a d i o ( ’ userTypeRadio ’ , ’ Administrator ’ , TRUE) ; ?>>< l a b e l f o r=”userTypeAdministrator”>Administrator</labe l>

107

Page 119: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<input type=”rad io ” id=”userTypeContentManager” name=”userTypeRadio” value=”Content Manager”<?php echo s e t r a d i o ( ’ userTypeRadio ’ , ’ Content Manager ’ ) ; ?>>< l a b e l f o r=”userTypeContentManager”>Content Manager</labe l>

<!−−<input type=”rad io ” id=”userTypeUser ” name=”userTypeRadio” value=”User” <?php echos e t r a d i o ( ’ userTypeRadio ’ , ’ User ’ ) ; ?>>< l a b e l f o r=”userTypeUser”>User</labe l>−−>

</div></tr><tr><td><l a b e l f o r=”ema i l addre s s”>&nbsp ; E−mail Address :</ labe l><td><input id=”ema i l addre s s ” name=”ema i l addre s s ” type=”text ” value=”<?php echo s e t v a l u e ( ’

emai l address ’ ) ; ?>”><span id=”ema i l v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”username”>&nbsp ; Username:</ labe l><td><input id=”username” name=”username” type=”text ” value=”<?php echo s e t v a l u e ( ’ username ’ ) ;

?>” ><span id=”u s r v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”password”>&nbsp ; Password :</ labe l><td><input id=”password” name=”password” type=”password” value=”<?php echo s e t v a l u e ( ’

password ’ ) ; ?>” ><span id=”pas sword ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”conf irm password”>&nbsp ; Confirm Password:</ labe l><td><input id=”conf i rm password ” name=”conf irm password ” type=”password” value=”<?php echo

s e t v a l u e ( ’ conf irm password ’ ) ; ?>”><span id=”con f i rmpas sword ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><button id=”addUserButton” type=”submit” name=”submit” value=”submit”>Add User</button><td><button id=”addUserBackButton” type=”button” name=”addUserBackButton” value=”Back” onc l i c k

=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home admin ’”>Back</button><button id=”addUserHomeButton” type=”button” name=”addUserHomeButton” value=”Home” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home admin ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#editUserButton , #editUserBackButton , #editUserHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#ed i tUserDia log ” ) . d i a l og ({autoOpen : true ,width : 650 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {

$(”#password ”) . keyup ( func t i on ( ) {i f ( $(”#conf i rm password ”) . va l ( ) . l ength >= 8) {i f ( $(”#conf i rm password ”) . va l ( ) !=$(”#password ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}

108

Page 120: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}e l s e i f ( $(”#password ”) . va l ( ) . l ength < 8) {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

pa s sword l eng th e r ro r . png ’ ) ” }) ;}e l s e {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” })}}) ;

$(”#conf i rm password ”) . keyup ( func t i on ( ) {i f ( $(”#password ”) . va l ( ) . l ength >=8) {i f ( $(”#conf i rm password ”) . va l ( ) !=$(”#password ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}}) ;}) ;

</s c r i p t></head><body><div id=”ed i tUserDia log ” t i t l e =”Change Password”><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font>

<?php echo form open (” home admin/ ed i t pa s sword use r /$username ”) ;?><center><table><tr></tr><tr></tr><tr><td><input id=”username” name=”username” type=”text ” s t y l e=” v i s i b i l i t y : hidden” value=”<?php

echo $username ; ?>” readonly=”readonly ” ></tr><tr><td><l a b e l f o r=”old password”>&nbsp ; Old Password:</ labe l><td><input id=”old password ” name=”old password ” type=”password” ></tr><tr><td><l a b e l f o r=”password”>&nbsp ; Password :</ labe l><td><input id=”password” name=”password” type=”password”><span id=”pas sword ve r i f y ” c l a s s=”

v e r i f y”></span></tr><tr><td><l a b e l f o r=”conf irm password”>&nbsp ; Confirm Password:</ labe l><td><input id=”conf i rm password ” name=”conf irm password ” type=”password”><span id=”

con f i rmpas sword ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><button id=”editUserButton ” type=”submit” name=”submit” value=”submit”>Change Password</

button><td><button id=”editUserBackButton” type=”button” name=”editUserBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home admin ’”>Back</button><button id=”editUserHomeButton” type=”button” name=”editUserHomeButton” value=”Back” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home admin ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>

109

Page 121: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ ( func t i on ( ) {$ ( ”#editUserButton , #editUserBackButton , #editUserHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#ed i tUserDia log ” ) . d i a l og ({autoOpen : true ,width : 650 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {

$(”#password ”) . keyup ( func t i on ( ) {i f ( $(”#conf i rm password ”) . va l ( ) . l ength >= 8) {i f ( $(”#conf i rm password ”) . va l ( ) !=$(”#password ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}

e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}e l s e i f ( $(”#password ”) . va l ( ) . l ength < 8) {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

pa s sword l eng th e r ro r . png ’ ) ” }) ;}e l s e {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” })}}) ;

$(”#conf i rm password ”) . keyup ( func t i on ( ) {i f ( $(”#password ”) . va l ( ) . l ength >=8) {i f ( $(”#conf i rm password ”) . va l ( ) !=$(”#password ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}}) ;}) ;

</s c r i p t></head><body><div id=”ed i tUserDia log ” t i t l e =”Change Password”><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font>

<?php echo form open (” home cmanager/ ed i t pa s sword use r /$username ”) ;?><center><table><tr></tr><tr></tr><tr><td><input id=”username” name=”username” type=”text ” s t y l e=” v i s i b i l i t y : hidden” value=”<?php

echo $username ; ?>” readonly=”readonly ” ></tr><tr><td><l a b e l f o r=”old password”>&nbsp ; Old Password:</ labe l><td><input id=”old password ” name=”old password ” type=”password” ></tr><tr><td><l a b e l f o r=”password”>&nbsp ; Password :</ labe l><td><input id=”password” name=”password” type=”password”><span id=”pas sword ve r i f y ” c l a s s=”

v e r i f y”></span></tr><tr><td><l a b e l f o r=”conf irm password”>&nbsp ; Confirm Password:</ labe l>

110

Page 122: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<td><input id=”conf i rm password ” name=”conf irm password ” type=”password”><span id=”con f i rmpas sword ve r i f y ” c l a s s=”v e r i f y”></span>

</tr><tr><td><button id=”editUserButton ” type=”submit” name=”submit” value=”submit”>Change Password</

button><td><button id=”editUserBackButton” type=”button” name=”editUserBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Back</button><button id=”editUserHomeButton” type=”button” name=”editUserHomeButton” value=”Back” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#editUserButton , #editUserBackButton , #editUserHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#ed i tUserDia log ” ) . d i a l og ({autoOpen : true ,width : 650 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {

$(”#password ”) . keyup ( func t i on ( ) {i f ( $(”#conf i rm password ”) . va l ( ) . l ength >= 8) {i f ( $(”#conf i rm password ”) . va l ( ) !=$(”#password ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}

e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}e l s e i f ( $(”#password ”) . va l ( ) . l ength < 8) {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

pa s sword l eng th e r ro r . png ’ ) ” }) ;}e l s e {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” })}}) ;

$(”#conf i rm password ”) . keyup ( func t i on ( ) {i f ( $(”#password ”) . va l ( ) . l ength >=8) {i f ( $(”#conf i rm password ”) . va l ( ) !=$(”#password ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;

111

Page 123: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}}) ;}) ;

</s c r i p t></head><body><div id=”ed i tUserDia log ” t i t l e =”Change Password”><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font>

<?php echo form open (” home user / ed i t pa s sword use r /$username ”) ;?><center><table><tr></tr><tr></tr><tr><td><input id=”username” name=”username” type=”text ” s t y l e=” v i s i b i l i t y : hidden” value=”<?php

echo $username ; ?>” readonly=”readonly ” ></tr><tr><td><l a b e l f o r=”old password”>&nbsp ; Old Password:</ labe l><td><input id=”old password ” name=”old password ” type=”password” ></tr><tr><td><l a b e l f o r=”password”>&nbsp ; Password :</ labe l><td><input id=”password” name=”password” type=”password”><span id=”pas sword ve r i f y ” c l a s s=”

v e r i f y”></span></tr><tr><td><l a b e l f o r=”conf irm password”>&nbsp ; Confirm Password:</ labe l><td><input id=”conf i rm password ” name=”conf irm password ” type=”password”><span id=”

con f i rmpas sword ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><button id=”editUserButton ” type=”submit” name=”submit” value=”submit”>Change Password</

button><td><button id=”editUserBackButton” type=”button” name=”editUserBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”editUserHomeButton” type=”button” name=”editUserHomeButton” value=”Back” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#editUserButton , #editUserBackButton , #editUserHomeButton ”) . button ( ) ;$ ( ”#userTypeRadioButtonSet , #genderRadioButtonSet ” ) . buttonset ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#b i r thdate ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# birthdate ’ ) . v a l i d ( ) ;i f ( $( ’# birthdate ’ ) . va 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 echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {

112

Page 124: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$(”#b i r t h d a t e v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /b i r t h d a t e r e qu i r e d e r r o r . png ’ ) ” }) ;

}}}) ;$ ( ”#ed i tUserDia log ” ) . d i a l og ({autoOpen : true ,width : 650 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#username ”) . keyup ( func t i on ( ) {i f ( $(”#username ”) . va l ( ) . l ength >= 4) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home admin/ check use r ” ,data : ”name=”+$(”#username ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images / c o r r e c t

. png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

u s e rname ex i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e i f ( $(”#username reg ”) . va l ( ) . l ength < 4) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

use rname l ength e r ro r . png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”#ema i l addre s s ”) . keyup ( func t i on ( ) {var emai l = $(”#ema i l addre s s ”) . va l ( ) ;i f ( emai l != 0) {i f ( i sVal idEmai lAddress ( emai l ) ) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home admin/ check emai l ” ,data : ” emai l=”+$(”#ema i l addre s s ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;emai l con=true ;r e g i s t e r s how ( ) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l e x i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l i n v a l i d e r r o r . png ’ ) ” }) ;}}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”# f i r s t name ”) . keyup ( func t i on ( ) {i f ( $( ’# f i r s t name ’ ) . va l ( ) != ’ ’ ) {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

f i r s t n ame r e q u i r e d e r r o r . png ’ ) ” }) ;}}) ;

$(”#last name ”) . keyup ( func t i on ( ) {i f ( $( ’# last name ’ ) . va l ( ) != ’ ’ ) {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

l a s t n ame r e qu i r e d e r r o r . png ’ ) ” }) ;}}) ;}) ;

f unc t i on isVal idEmai lAddress ( emailAddress ) {

113

Page 125: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

var pattern = new RegExp (/ˆ ( ( ” [\w−\s ]+”) | ( [ \w− ]+(? :\ . [\w−]+)∗) | ( ” [ \w−\s ]+”) ( [\w− ]+(? :\ . [\w−]+)∗) ) (@( ( ? : [ \w−]+\.)∗\w[\w− ]{0 ,66}) \ . ( [ 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 ) ;

r e turn pattern . t e s t ( emailAddress ) ;}

</s c r i p t></head><body><div id=”ed i tUserDia log ” t i t l e =”Edit P r o f i l e In format ion”><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font>

<?php echo form open (” home admin/ e d i t p r o f i l e u s e r /$username ”) ;?><center><table><tr></tr><tr></tr><tr><td><l a b e l f o r=”username”>&nbsp ; Username:</ labe l><td><input id=”username” name=”username” type=”text ” value=”<?php echo $username ; ?>”

readonly=”readonly”><span id=”u s r v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”f i r s t name”>&nbsp ; F i r s t Name:</ labe l><td><input id=”f i r s t name ” name=”f i r s t name ” type=”text ” value=”<?php echo $ f i r s t name ; ?>”><span id=” f i r s t n ame v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”middle name”>&nbsp ; Middle Name:</ labe l><td><input id=”middle name” name=”middle name” type=”text ” value=”<?php echo $middle name ;

?>”>(Optional )</tr><tr><td><l a b e l f o r=”last name”>&nbsp ; Last Name:</ labe l><td><input id=”last name ” name=”last name ” type=”text ” value=”<?php echo $last name ; ?>”><span id=”l a s tname ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”b i r thdate”>&nbsp ; Birthdate :</ labe l><td><input id=”b i r thdate ” name=”b i r thdate ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value=”<?

php echo $birthday ; ?>” readonly=”readonly”><a h r e f=”#bi r thdate ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><span id=”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></tr><tr><td><l a b e l f o r=”gender”>&nbsp ; Gender:</ labe l><td><div id=”genderRadioButtonSet”><input type=”rad io ” id=”genderMale” name=”genderRadio ” value=”Male” <?php i f ( $gender == ”Male

”) echo ” checked ” ; ?>>< l a b e l f o r=”genderMale”>Male</labe l><input type=”rad io ” id=”genderFemale” name=”genderRadio ” value=”Female” <?php i f ( $gender== ”

Female ”) echo ” checked ” ; ?>>< l a b e l f o r=”genderFemale”>Female</labe l></div></tr><tr><td><l a b e l f o r=”use r type”>&nbsp ; User Type:</ labe l><td><div id=”userTypeRadioButtonSet”><input type=”rad io ” id=”userTypeAdministrator ” name=”userTypeRadio” value=”Administrator ” <?

php i f ( $use r type == ”Administrator ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeAdministrator”>Administrator</labe l>

<input type=”rad io ” id=”userTypeContentManager” name=”userTypeRadio” value=”Content Manager”<?php i f ( $use r type== ”Content Manager ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeContentManager”>Content Manager</labe l>

<input type=”rad io ” id=”userTypeUser ” name=”userTypeRadio” value=”User” <?php i f ( $use r type ==”User ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeUser”>User</labe l>

</div></tr><tr><td><l a b e l f o r=”ema i l addre s s”>&nbsp ; E−mail Address :</ labe l><td><input id=”ema i l addre s s ” name=”ema i l addre s s ” type=”text ” value=”<?php echo

$ema i l addre s s ; ?>”><span id=”ema i l v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><button id=”editUserButton ” type=”submit” name=”submit” value=”submit”>Update P ro f i l e </

button><td><button id=”editUserBackButton” type=”button” name=”editUserBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home admin ’”>Back</button><button id=”editUserHomeButton” type=”button” name=”editUserHomeButton” value=”Home” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home admin ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / s t y l e . c s s”>

114

Page 126: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<l i n k r e l=”s t y l e s h e e t ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” />

<s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></s c r i p t>

<s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom. j s ”></s c r i p t>

<s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#editUserButton , #editUserBackButton , #editUserHomeButton ”) . button ( ) ;$ ( ”#userTypeRadioButtonSet , #genderRadioButtonSet ” ) . buttonset ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#b i r thdate ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# birthdate ’ ) . v a l i d ( ) ;i f ( $( ’# birthdate ’ ) . va 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 echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”#b i r t h d a t e v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

b i r t h d a t e r e qu i r e d e r r o r . png ’ ) ” }) ;}}}) ;$ ( ”#ed i tUserDia log ” ) . d i a l og ({autoOpen : true ,width : 650 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#username ”) . keyup ( func t i on ( ) {i f ( $(”#username ”) . va l ( ) . l ength >= 4) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home cmanager/ check use r ” ,data : ”name=”+$(”#username ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images / c o r r e c t

. png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

u s e rname ex i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e i f ( $(”#username reg ”) . va l ( ) . l ength < 4) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

use rname l ength e r ro r . png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”#ema i l addre s s ”) . keyup ( func t i on ( ) {var emai l = $(”#ema i l addre s s ”) . va l ( ) ;i f ( emai l != 0) {i f ( i sVal idEmai lAddress ( emai l ) ) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home cmanager/ check emai l ” ,data : ” emai l=”+$(”#ema i l addre s s ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;emai l con=true ;r e g i s t e r s how ( ) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l e x i s t s e r r o r . png ’ ) ” }) ;}

115

Page 127: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}}) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l i n v a l i d e r r o r . png ’ ) ” }) ;}}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”# f i r s t name ”) . keyup ( func t i on ( ) {i f ( $( ’# f i r s t name ’ ) . va l ( ) != ’ ’ ) {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

f i r s t n ame r e q u i r e d e r r o r . png ’ ) ” }) ;}}) ;

$(”#last name ”) . keyup ( func t i on ( ) {i f ( $( ’# last name ’ ) . va l ( ) != ’ ’ ) {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

l a s t n ame r e qu i r e d e r r o r . png ’ ) ” }) ;}}) ;}) ;

f unc t i on isVal idEmai lAddress ( emailAddress ) {var pattern = new RegExp (/ˆ ( ( ” [\w−\s ]+”) | ( [ \w− ]+(? :\ . [\w−]+)∗) | ( ” [ \w−\s ]+”) ( [\w− ]+(? :\ . [\w−]+)

∗) ) (@( ( ? : [ \w−]+\.)∗\w[\w− ]{0 ,66}) \ . ( [ 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 ) ;

r e turn pattern . t e s t ( emailAddress ) ;}

</s c r i p t></head><body><div id=”ed i tUserDia log ” t i t l e =”Edit P r o f i l e In format ion”><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font>

<?php echo form open (” home cmanager/ e d i t p r o f i l e u s e r /$username ”) ;?><center><table><tr></tr><tr></tr><tr><td s t y l e=” v i s i b i l i t y : hidden”><div id=”userTypeRadioButtonSet”><input type=”rad io ” id=”userTypeAdministrator ” name=”userTypeRadio” value=”Administrator ” <?

php i f ( $use r type == ”Administrator ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeAdministrator”>Administrator</labe l>

<input type=”rad io ” id=”userTypeContentManager” name=”userTypeRadio” value=”Content Manager”<?php i f ( $use r type== ”Content Manager ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeContentManager”>Content Manager</labe l>

<input type=”rad io ” id=”userTypeUser ” name=”userTypeRadio” value=”User” <?php i f ( $use r type ==”User ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeUser”>User</labe l>

</div></tr><tr><td><l a b e l f o r=”username”>&nbsp ; Username:</ labe l><td><input id=”username” name=”username” type=”text ” value=”<?php echo $username ; ?>”

readonly=”readonly ” ><span id=”u s r v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”f i r s t name”>&nbsp ; F i r s t Name:</ labe l><td><input id=”f i r s t name ” name=”f i r s t name ” type=”text ” value=”<?php echo $ f i r s t name ; ?>”><span id=” f i r s t n ame v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”middle name”>&nbsp ; Middle Name:</ labe l><td><input id=”middle name” name=”middle name” type=”text ” value=”<?php echo $middle name ;

?>”>(Optional )</tr><tr><td><l a b e l f o r=”last name”>&nbsp ; Last Name:</ labe l><td><input id=”last name ” name=”last name ” type=”text ” value=”<?php echo $last name ; ?>”><span id=”l a s tname ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”b i r thdate”>&nbsp ; Birthdate :</ labe l><td><input id=”b i r thdate ” name=”b i r thdate ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value=”<?

php echo $birthday ; ?>” readonly=”readonly”><a h r e f=”#bi r thdate ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><span id=”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></tr><tr><td><l a b e l f o r=”gender”>&nbsp ; Gender:</ labe l><td><div id=”genderRadioButtonSet”>

116

Page 128: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<input type=”rad io ” id=”genderMale” name=”genderRadio ” value=”Male” <?php i f ( $gender == ”Male”) echo ” checked ” ; ?>>< l a b e l f o r=”genderMale”>Male</labe l>

<input type=”rad io ” id=”genderFemale” name=”genderRadio ” value=”Female” <?php i f ( $gender== ”Female ”) echo ” checked ” ; ?>>< l a b e l f o r=”genderFemale”>Female</labe l>

</div></tr><tr><td><l a b e l f o r=”ema i l addre s s”>&nbsp ; E−mail Address :</ labe l><td><input id=”ema i l addre s s ” name=”ema i l addre s s ” type=”text ” value=”<?php echo

$ema i l addre s s ; ?>”><span id=”ema i l v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><button id=”editUserButton ” type=”submit” name=”submit” value=”submit”>Update P ro f i l e </

button><td><button id=”editUserBackButton” type=”button” name=”editUserBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Back</button><td><button id=”editUserHomeButton” type=”button” name=”editUserHomeButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#editUserButton , #editUserBackButton , #editUserHomeButton ”) . button ( ) ;$ ( ”#userTypeRadioButtonSet , #genderRadioButtonSet ” ) . buttonset ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#b i r thdate ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# birthdate ’ ) . v a l i d ( ) ;i f ( $( ’# birthdate ’ ) . va 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 echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”#b i r t h d a t e v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

b i r t h d a t e r e qu i r e d e r r o r . png ’ ) ” }) ;}}}) ;$ ( ”#ed i tUserDia log ” ) . d i a l og ({autoOpen : true ,width : 650 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#username ”) . keyup ( func t i on ( ) {i f ( $(”#username ”) . va l ( ) . l ength >= 4) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home user / check use r ” ,data : ”name=”+$(”#username ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images / c o r r e c t

. png ’ ) ” }) ;}

117

Page 129: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

u s e rname ex i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e i f ( $(”#username reg ”) . va l ( ) . l ength < 4) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

use rname l ength e r ro r . png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”#ema i l addre s s ”) . keyup ( func t i on ( ) {var emai l = $(”#ema i l addre s s ”) . va l ( ) ;i f ( emai l != 0) {i f ( i sVal idEmai lAddress ( emai l ) ) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home user / check emai l ” ,data : ” emai l=”+$(”#ema i l addre s s ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;emai l con=true ;r e g i s t e r s how ( ) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l e x i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l i n v a l i d e r r o r . png ’ ) ” }) ;}}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”# f i r s t name ”) . keyup ( func t i on ( ) {i f ( $( ’# f i r s t name ’ ) . va l ( ) != ’ ’ ) {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

f i r s t n ame r e q u i r e d e r r o r . png ’ ) ” }) ;}}) ;

$(”#last name ”) . keyup ( func t i on ( ) {i f ( $( ’# last name ’ ) . va l ( ) != ’ ’ ) {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

l a s t n ame r e qu i r e d e r r o r . png ’ ) ” }) ;}}) ;}) ;

f unc t i on isVal idEmai lAddress ( emailAddress ) {var pattern = new RegExp (/ˆ ( ( ” [\w−\s ]+”) | ( [ \w− ]+(? :\ . [\w−]+)∗) | ( ” [ \w−\s ]+”) ( [\w− ]+(? :\ . [\w−]+)

∗) ) (@( ( ? : [ \w−]+\.)∗\w[\w− ]{0 ,66}) \ . ( [ 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 ) ;

r e turn pattern . t e s t ( emailAddress ) ;}

</s c r i p t></head><body><div id=”ed i tUserDia log ” t i t l e =”Edit P r o f i l e In format ion”><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font>

<?php echo form open (” home user / e d i t p r o f i l e u s e r /$username ”) ;?><center><table><tr></tr><tr></tr><tr><td s t y l e=” v i s i b i l i t y : hidden”><div id=”userTypeRadioButtonSet”><input type=”rad io ” id=”userTypeAdministrator ” name=”userTypeRadio” value=”Administrator ” <?

php i f ( $use r type == ”Administrator ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeAdministrator”>Administrator</labe l>

<input type=”rad io ” id=”userTypeContentManager” name=”userTypeRadio” value=”Content Manager”<?php i f ( $use r type== ”Content Manager ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeContentManager”>Content Manager</labe l>

<input type=”rad io ” id=”userTypeUser ” name=”userTypeRadio” value=”User” <?php i f ( $use r type ==”User ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeUser”>User</labe l>

118

Page 130: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

</div></tr><tr><td><l a b e l f o r=”username”>&nbsp ; Username:</ labe l><td><input id=”username” name=”username” type=”text ” value=”<?php echo $username ; ?>”

readonly=”readonly ” ><span id=”u s r v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”f i r s t name”>&nbsp ; F i r s t Name:</ labe l><td><input id=”f i r s t name ” name=”f i r s t name ” type=”text ” value=”<?php echo $ f i r s t name ; ?>”><span id=” f i r s t n ame v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”middle name”>&nbsp ; Middle Name:</ labe l><td><input id=”middle name” name=”middle name” type=”text ” value=”<?php echo $middle name ;

?>”>(Optional )</tr><tr><td><l a b e l f o r=”last name”>&nbsp ; Last Name:</ labe l><td><input id=”last name ” name=”last name ” type=”text ” value=”<?php echo $last name ; ?>”><span id=”l a s tname ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”b i r thdate”>&nbsp ; Birthdate :</ labe l><td><input id=”b i r thdate ” name=”b i r thdate ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value=”<?

php echo $birthday ; ?>” readonly=”readonly”><a h r e f=”#bi r thdate ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><span id=”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></tr><tr><td><l a b e l f o r=”gender”>&nbsp ; Gender:</ labe l><td><div id=”genderRadioButtonSet”><input type=”rad io ” id=”genderMale” name=”genderRadio ” value=”Male” <?php i f ( $gender == ”Male

”) echo ” checked ” ; ?>>< l a b e l f o r=”genderMale”>Male</labe l><input type=”rad io ” id=”genderFemale” name=”genderRadio ” value=”Female” <?php i f ( $gender== ”

Female ”) echo ” checked ” ; ?>>< l a b e l f o r=”genderFemale”>Female</labe l></div></tr><tr><td><l a b e l f o r=”ema i l addre s s”>&nbsp ; E−mail Address :</ labe l><td><input id=”ema i l addre s s ” name=”ema i l addre s s ” type=”text ” value=”<?php echo

$ema i l addre s s ; ?>”><span id=”ema i l v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><button id=”editUserButton ” type=”submit” name=”submit” value=”submit”>Update P ro f i l e </

button><td><button id=”editUserBackButton” type=”button” name=”editUserBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”editUserHomeButton” type=”button” name=”editUserHomeButton” value=”Home” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#editUserButton , #editUserBackButton , #editUserHomeButton ”) . button ( ) ;$ ( ”#userTypeRadioButtonSet , #genderRadioButtonSet , #statusRadioButtonSet ” ) . buttonset ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#b i r thdate ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,

119

Page 131: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

onClose : func t i on ( ) {$( ’# birthdate ’ ) . v a l i d ( ) ;i f ( $( ’# birthdate ’ ) . va 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 echo ba s e u r l ( ) ;?> l ayout / images /

yes . png ’ ) ” }) ;} e l s e {$(”#b i r t h d a t e v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

no . png ’ ) ” }) ;}}}) ;$ ( ”#ed i tUserDia log ” ) . d i a l og ({autoOpen : true ,width : 650 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#username ”) . keyup ( func t i on ( ) {i f ( $(”#username ”) . va l ( ) . l ength >= 4) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home admin/ check use r ” ,data : ”name=”+$(”#username ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images / yes . png

’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /no . png

’ ) ” }) ;}}}) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”#ema i l addre s s ”) . keyup ( func t i on ( ) {var emai l = $(”#ema i l addre s s ”) . va l ( ) ;i f ( emai l != 0) {i f ( i sVal idEmai lAddress ( emai l ) ) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?>home admin/ check emai l ” ,data : ” emai l=”+$(”#ema i l addre s s ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images / yes .

png ’ ) ” }) ;emai l con=true ;r e g i s t e r s how ( ) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /no .

png ’ ) ” }) ;}}}) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /no .

png ’ ) ” }) ;}}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”# f i r s t name ”) . keyup ( func t i on ( ) {i f ( $( ’# f i r s t name ’ ) . va l ( ) != ’ ’ ) {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

yes . png ’ ) ” }) ;} e l s e {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

no . png ’ ) ” }) ;}}) ;

$(”#last name ”) . keyup ( func t i on ( ) {i f ( $( ’# last name ’ ) . va l ( ) != ’ ’ ) {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

yes . png ’ ) ” }) ;} e l s e {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /no

. png ’ ) ” }) ;}}) ;}) ;

120

Page 132: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

f unc t i on isVal idEmai lAddress ( emailAddress ) {var pattern = new RegExp (/ˆ ( ( ” [\w−\s ]+”) | ( [ \w− ]+(? :\ . [\w−]+)∗) | ( ” [ \w−\s ]+”) ( [\w− ]+(? :\ . [\w−]+)

∗) ) (@( ( ? : [ \w−]+\.)∗\w[\w− ]{0 ,66}) \ . ( [ 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 ) ;

r e turn pattern . t e s t ( emailAddress ) ;}

</s c r i p t></head><body><div id=”ed i tUserDia log ” t i t l e =”Edit User”><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php $username = $item [ ’ username ’ ] ; ?><?php $ f i r s t name = $item [ ’ f i r s t name ’ ] ; ?><?php $middle name = $item [ ’ middle name ’ ] ; ?><?php $last name = $item [ ’ last name ’ ] ; ?><?php $b i r thdate = $item [ ’ birthday ’ ] ; ?><?php $genderRadio = $item [ ’ gender ’ ] ; ?><?php $userTypeRadio = $item [ ’ user type ’ ] ; ?><?php $ema i l addre s s = $item [ ’ emai l address ’ ] ; ?><?php $statusRadio = $item [ ’ s tatus ’ ] ; ?><?php echo form open (” home admin/ e d i t u s e r /$username ”) ;?><center><table><tr></tr><tr></tr><tr><td><l a b e l f o r=”username”>&nbsp ; Username:</ labe l><td><input id=”username” name=”username” type=”text ” value=”<?php echo $username ; ?>” ><span id=”u s r v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”f i r s t name”>&nbsp ; F i r s t Name:</ labe l><td><input id=”f i r s t name ” name=”f i r s t name ” type=”text ” value=”<?php echo $ f i r s t name ; ?>”><span id=” f i r s t n ame v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”middle name”>&nbsp ; Middle Name:</ labe l><td><input id=”middle name” name=”middle name” type=”text ” value=”<?php echo $middle name ;

?>”>(Optional )</tr><tr><td><l a b e l f o r=”last name”>&nbsp ; Last Name:</ labe l><td><input id=”last name ” name=”last name ” type=”text ” value=”<?php echo $last name ; ?>”><span id=”l a s tname ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”b i r thdate”>&nbsp ; Birthdate :</ labe l><td><input id=”b i r thdate ” name=”b i r thdate ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value=”<?

php echo $b i r thdate ; ?>” readonly=”readonly”><a h r e f=”#bi r thdate ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><span id=”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></tr><tr><td><l a b e l f o r=”gender”>&nbsp ; Gender:</ labe l><td><div id=”genderRadioButtonSet”><input type=”rad io ” id=”genderMale” name=”genderRadio ” value=”Male” <?php i f ( $genderRadio == ”

Male ”) echo ” checked ” ; ?>>< l a b e l f o r=”genderMale”>Male</labe l><input type=”rad io ” id=”genderFemale” name=”genderRadio ” value=”Female” <?php i f ( $genderRadio

== ”Female ”) echo ” checked ” ; ?>>< l a b e l f o r=”genderFemale”>Female</labe l></div></tr><tr><td><l a b e l f o r=”use r type”>&nbsp ; User Type:</ labe l><td><div id=”userTypeRadioButtonSet”><input type=”rad io ” id=”userTypeAdministrator ” name=”userTypeRadio” value=”Administrator ” <?

php i f ( $userTypeRadio == ”Administrator ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeAdministrator”>Administrator</labe l>

<input type=”rad io ” id=”userTypeContentManager” name=”userTypeRadio” value=”Content Manager”<?php i f ( $userTypeRadio == ”Content Manager ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeContentManager”>Content Manager</labe l>

<input type=”rad io ” id=”userTypeUser ” name=”userTypeRadio” value=”User” <?php i f ($userTypeRadio == ”User ”) echo ” checked ” ; ?>>< l a b e l f o r=”userTypeUser”>User</labe l>

</div></tr><tr><td><l a b e l f o r=”ema i l addre s s”>&nbsp ; E−mail Address :</ labe l><td><input id=”ema i l addre s s ” name=”ema i l addre s s ” type=”text ” value=”<?php echo

$ema i l addre s s ; ?>”><span id=”ema i l v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”s ta tu s”>&nbsp ; Status :</ labe l><td><div id=”statusRadioButtonSet”><input type=”rad io ” id=”statusAct ivated ” name=”statusRadio ” value=”Activated ” <?php i f (

$statusRadio == ”Activated ”) echo ” checked ” ; ?>>< l a b e l f o r=”s ta tusAct ivated”>Activated</labe l>

<input type=”rad io ” id=”statusDeact ivated ” name=”statusRadio ” value=”Deact ivated ” <?php i f ($statusRadio == ”Deact ivated ”) echo ” checked ” ; ?>>< l a b e l f o r=”statusDeact ivated”>Deactivated</labe l>

</div></tr><tr><td><button id=”editUserButton ” type=”submit” name=”submit” value=”submit”>Update User</button

>

121

Page 133: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<td><button id=”editUserBackButton” type=”button” name=”editUserBackButton” value=”Back”onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home admin ’”>Back</button>

<button id=”editUserHomeButton” type=”button” name=”editUserHomeButton” value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home admin ’”>Home</button>

</tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( document ) . ready ( func t i on ( ) {$(”#ad−inner−nav ”) . hide ( ) ;

$ ( ” . ad−top−nav ”) . mouseenter ( func t i on ( ) {$(”#ad−inner−nav ”) . fadeIn ( ) ;}) ;

$ ( ” . ad−top−nav ”) . mouseleave ( func t i on ( ) {$(”#ad−inner−nav ”) . fadeOut ( ) ;}) ;

$ ( ”#viewProf i l eBoxDia log ” ) . d i a l og ({autoOpen : f a l s e ,width : 650 ,modal : true ,closeOnEscape : f a l s e}) ;

// Link to open the d i a l og$ ( ”#viewProf i leBoxDialogButton ” ) . c l i c k ( func t i on ( event ) {$ ( ”#viewProf i l eBoxDia log ” ) . d i a l og ( ”open” ) ;event . preventDefau l t ( ) ;}) ;$(”#success msg ”) . fadeOut (5000) ;

}) ;

$ ( func t i on ( ) {$ ( ”#logoutButton , #userSearchButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#search ” ) . autocomplete ( {source : func t i on ( request , re sponse ) {$ . ajax ( {ur l : ”<?php echo s i t e u r l ( ’ home admin/ sugges t i ons ’ ) ; ?>”,data : {term : $(”#search ”) . va l ( )} ,dataType : ” j son ” ,type : ”POST” ,suc c e s s : func t i on ( data ) {re sponse ( data ) ;}}) ;} ,minLength : 1}) ;}) ;</s c r i p t></head><body><div id=”conta ine r”>

<div id=”header”></div>

<div id=”body”>

<div id=”logoutBox”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ad−top−nav”>

122

Page 134: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

< l i id =”se t t ingsButton ” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”<?php echo $ f i r s t name ;?>”>

<span c l a s s=”ui−i con ui−icon−person”></span><span c l a s s=”s e t t i ng s−person”><?php echo$ f i r s t name ; ?> (<?php echo $use r type ; ?>)</span>

<span c l a s s=”ui−i con ui−icon−t r i ang 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 id=”ad−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ad−inner−nav”><div id=”viewProf i leBoxDialogButton ” c l a s s=”ad−inner−nav−opt ion ” t i t l e =”P r o f i l e In format ion”><

span c l a s s=”ui−i con ui−icon−s c r i p t”></span>P r o f i l e Information</div><a h r e f=”<?php echo 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 echo $username ; ?>”><div

c l a s s=”ad−inner−nav−opt ion ” t i t l e =”Edit P r o f i l e”><span c l a s s=”ui−i con ui−icon−penc i l”></span>Edit P ro f i l e </div>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home admin/ ed i t pa s sword use r /<?php echo $username ; ?>”><divc l a s s=”ad−inner−nav−opt ion ” t i t l e =”Change Password”><span c l a s s=”ui−i con ui−icon−gear”></

span>Change Password</div><a h r e f=”<?php echo s i t e u r l ( ) ; ?>home admin/ logout”><div c l a s s=”ad−inner−nav−opt ion ” t i t l e =”

Logout”><span c l a s s=”ui−i con ui−icon−key”></span>Logout</div></a></ l i ></ul></div><div id=”viewPro f i l eBoxDia log ” t i t l e =”P r o f i l e In format ion”><table><tr><td>Name :<td><?php echo $ f i r s t name ; ?> <?php echo $last name ; ?></tr><tr><td>Username :<td><?php echo $username ; ?></tr><tr><td>User Type :<td><?php echo $use r type ; ?></tr><tr><td>E−mail Address :<td><?php echo $ema i l addre s s ; ?></tr><tr><td>Gender :<td><?php echo $gender ; ?></tr><tr><td>Birthday :<td><?php echo $birthday ; ?></tr></table></div>

<div id=”manageUserAccountsBox”><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><div id=”manageUserAccountsHeading” c l a s s=”ui−widget−header ui−corner−a l l ”><center><h2>&nbsp ; Manage User Accounts</h2></center></div>

<div id=”viewUsersBox”><br><?=form open ( ’ home admin/ search ’ ) ;?><?php $search = array ( ’ name’=>’ search ’ , ’ id ’=>’ search ’ , ’ value ’=> ’ ’ ,) ; ?><center><?=form input ( $search ) ;?><button id=”userSearchButton ” type=”submit” value=””>Search</

button></center><?=fo rm c l o s e ( ) ;?>

<div id=”addUserBox”><a h r e f=”<?php echo s i t e u r l ( ) ; ?>home admin/ add user”><p><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i id =”addUserDialogButton” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Add User”><span

c l a s s=”ui−i con ui−icon−p lu s th i ck”></span>Add User &nbsp;</ l i ></ul></p></a></div>

<?php i f ( i s a r r a y ( $query ) && count ( $query ) ) { ?><center><table><tr><th s t y l e=”d i sp l ay : none;”>ID</th><th>Username</th><th>F i r s t Name</th><th>Middle Name</th><th>Last Name</th><th>User Type</th><th>E−mail Address</th><th>Gender</th><th>Birthday</th><th>Age</th><th>Actions</th><th>Status</th></tr><?php fo reach ( $query as $item ) : ?><?php $username= $item−>username ; ?><tr><td s t y l e=”d i sp l ay : none;”><?= $item−>u s e r i d ?></td><td><?= $item−>username ?></td>

123

Page 135: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<td><?= $item−>f i r s t name ?></td><td><?= $item−>middle name ?></td><td><?= $item−>last name ?></td><td><?= $item−>use r type ?></td><td><?= $item−>ema i l addre s s ?></td><td><?= $item−>gender ?></td><td><?= date (”Y−M−d” , s t r t o t ime ( $item−>birthday ) ) ; ?></td><td><?= d a t e d i f f ( da t e c r e a t e ( $item−>birthday ) , da t e c r e a t e ( ’ today ’ ) )−>y ; ?></td><td><a id=”editUserDia logButton ” c l a s s=”editUserDia logButton ” hr e f = ’ . . / home admin/ e d i t u s e r /<?php

echo $username ?>’><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Edit”><span c l a s s=”ui−i con ui−icon−pen c i l”></span></ l i ></ul></a><a h r e f =”. ./ home admin/ d e l e t e u s e r /<?php echo $username ; ?>” onc l i c k=”return conf irm ( ’ Are you

sure you want to d e l e t e ? ’ )”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Delete”><span c l a s s=”ui−i con ui−icon−t rash”></span></ l i ></ul></a></td><td><?= $item−>s t a tu s ?></td></tr><?php endforeach ;?></table></center><?php } ?></div></div></div></div><p c l a s s=”f o o t e r”>Page rendered in <strong>{e l apsed t ime}</strong> seconds</p></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( document ) . ready ( func t i on ( ) {$(”#cm−inner−nav ”) . hide ( ) ;

$ ( ” . cm−top−nav ”) . mouseenter ( func t i on ( ) {$(”#cm−inner−nav ”) . fadeIn ( ) ;}) ;

$ ( ” . cm−top−nav ”) . mouseleave ( func t i on ( ) {$(”#cm−inner−nav ”) . fadeOut ( ) ;}) ;

$(”#content−inner−nav ”) . hide ( ) ;

$ ( ” . content−top−nav ”) . mouseenter ( func t i on ( ) {$(”#content−inner−nav ”) . fadeIn ( ) ;}) ;

$ ( ” . content−top−nav ”) . mouseleave ( func t i on ( ) {$(”#content−inner−nav ”) . fadeOut ( ) ;}) ;

$(”#content−content−inner−nav ”) . hide ( ) ;

$ ( ” . content−content−top−nav ”) . mouseenter ( func t i on ( ) {$(”#content−content−inner−nav ”) . fadeIn ( ) ;}) ;

$ ( ” . content−content−top−nav ”) . mouseleave ( func t i on ( ) {$(”#content−content−inner−nav ”) . fadeOut ( ) ;}) ;

$ ( ”#viewProf i l eBoxDia log ” ) . d i a l og ({autoOpen : f a l s e ,width : 650 ,modal : true ,closeOnEscape : f a l s e}) ;

// Link to open the d i a l og$ ( ”#viewProf i leBoxDialogButton ” ) . c l i c k ( func t i on ( event ) {$ ( ”#viewProf i l eBoxDia log ” ) . d i a l og ( ”open” ) ;

124

Page 136: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

event . preventDefau l t ( ) ;}) ;

$(”#success msg ”) . fadeOut (5000) ;

}) ;

$ ( func t i on ( ) {$ ( ”#logoutButton , #userSearchButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;}) ;</s c r i p t></head><body><div id=”conta ine r”>

<div id=”header”></div>

<div id=”body”>

<div id=”logoutBox”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x cm−top−nav”>< l i id =”se t t ingsButton ” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”<?php echo $ f i r s t name ;

?>”><span c l a s s=”ui−i con ui−icon−person”></span><span c l a s s=”s e t t i ng s−person”><?php echo

$ f i r s t name ; ?> (<?php echo $use r type ; ?>)</span><span c l a s s=”ui−i con ui−icon−t r i ang 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 id=”cm−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l cm−inner−nav”><div id=”viewProf i leBoxDialogButton ” c l a s s=”cm−inner−nav−opt ion ” t i t l e =”P r o f i l e In format ion”><

span c l a s s=”ui−i con ui−icon−s c r i p t”></span>P r o f i l e Information</div><a h r e f=”<?php echo 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 echo $username ; ?>”><

div c l a s s=”cm−inner−nav−opt ion ” t i t l e =”Edit P r o f i l e”><span c l a s s=”ui−i con ui−icon−pen c i l”></span>Edit P ro f i l e </div>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home cmanager/ ed i t pa s sword use r /<?php echo $username ; ?>”><div c l a s s=”cm−inner−nav−opt ion ” t i t l e =”Change Password”><span c l a s s=”ui−i con ui−icon−gear”></span>Change Password</div>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home cmanager/ logout”><div c l a s s=”cm−inner−nav−opt ion ” t i t l e=”Logout”><span c l a s s=”ui−i con ui−icon−key”></span>Logout</div></a>

</ l i ></ul></div>

<div id=”viewPro f i l eBoxDia log ” t i t l e =”P r o f i l e In format ion”><table><tr><td>Name :<td><?php echo $ f i r s t name ; ?> <?php echo $last name ; ?></tr><tr><td>Username :<td><?php echo $username ; ?></tr><tr><td>User Type :<td><?php echo $use r type ; ?></tr><tr><td>E−mail Address :<td><?php echo $ema i l addre s s ; ?></tr><tr><td>Gender :<td><?php echo $gender ; ?></tr><tr><td>Birthday :<td><?php echo $birthday ; ?></tr></table></div>

<div id=”manageContentBox”><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><div id=”manageContentHeading” c l a s s=”ui−widget−header ui−corner−a l l ”><center><h2>&nbsp ; Manage Content</h2></center></div>

<div id=”contentMenuBox”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x content−top−nav”>< l i id =”addContentButton” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Add Content”><span c l a s s=”ui−i con ui−icon−p lu s th i ck”></span><span c l a s s=”content−p lu s th i ck”>Add Content</

span><span c l a s s=”ui−i con ui−icon−t r i ang l e−1−s content−t r i a n g l e”></span></ l i >< l i id=”content−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l content−inner−nav”>

125

Page 137: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home cmanager/ add f e l i t em”><div c l a s s=”content−inner−nav−opt ion ” t i t l e =”Add Food Exchange L i s t Item”><span c l a s s=”ui−i con ui−icon−pin−s”></span>Food Exchange Item</div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home cmanager/ add rec ipe”><div c l a s s=”content−inner−nav−opt ion ” t i t l e =”Add Recipe”><span c l a s s=”ui−i con ui−icon−c l i pboard”></span>Recipe</div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home cmanager/ recommend dai ly meals”><div c l a s s=”content−inner−nav−opt ion ” t i t l e =”Add Daily Meal Plan”><span c l a s s=”ui−i con ui−icon−l i g h tbu lb”></span>Daily Meal Plan</div>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home cmanager/ add hea l th t ip”><div c l a s s=”content−inner−nav−opt ion ” t i t l e =”Add Health Tip”><span c l a s s=”ui−i con ui−icon−l i g h tbu lb”></span>Health Tip</div></a>

</ l i ></ul><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x content−content−top−nav”>< l i id =”viewContentButton” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View”><span c l a s s=”ui−i con ui−icon−s t a r”></span><span c l a s s=”content−content−s t a r”>View</span><span c l a s s=”ui−i con ui−icon−t r i ang l e−1−s content−content−t r i a n g l e”></span></ l i >< l i id=”content−content−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l content−content−inner

−nav”><a h r e f=”<?php echo s i t e u r l ( ) ; ?>home cmanager/ show c r ea t ed r e c i p e s”><div c l a s s=”content−

content−inner−nav−opt ion ” t i t l e =”Recipes Created”><span c l a s s=”ui−i con ui−icon−c l i pboard”></span>Recipes Created</div></a>

</ l i ></ul></div>

<div id=”viewUsersBox”><br><?=form open ( ’ home cmanager/ s e a r c h f e l ’ ) ;?><?php $ s e a r c h f e l = array ( ’ name’=>’ s e a r c h f e l ’ , ’ id ’=>’ s e a r c h f e l ’ , ’ value ’=> ’ ’ ,) ; ?><center>Food Exchange L i s t : <?=form input ( $ s e a r c h f e l ) ;?><button id=”userSearchButton ” type=”submit” value=”” t i t l e =”Search Food Exchange L i s t”>Search

</button></center><?=fo rm c l o s e ( ) ;?><?=form open ( ’ home cmanager/ search ht ’ ) ;?><?php $sea rch ht = array ( ’ name’=>’ s earch ht ’ , ’ id ’=>’ s earch ht ’ , ’ value ’=> ’ ’ ,) ; ?><center>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; Health Tips :

<?=form input ( $ sea rch ht ) ;?><button id=”userSearchButton ” type=”submit” value=”” t i t l e =”Search Health Tips”>Search</button

></center><?=fo rm c l o s e ( ) ;?>

<?php i f ( i s a r r a y ( $ qu e r y f e l ) ) { ?><center><table><tr><th>L i s t Group</th><th>Food Group</th><th>Food Group Category</th><th>Food Name</th><th>Measure</th><th>Carbohydrate</th><th>Protein</th><th>Fat</th><th>Energy</th><th>Weight as Purchased</th><th>Weight Edible Portion</th><th>Actions</th></tr><?php fo reach ( $qu e r y f e l as $item ) : ?><?php $ f o od e x c h an g e l i s t i d = $item−>f o o d e x c h an g e l i s t i d ?><tr><td><?= $item−>l i s t g r o u p ?></td><td><?= $item−>food group ?></td><td><?= $item−>f ood group category ?></td><td><?= $item−>food name ?></td><td><?= $item−>measure ?></td><td><?= $item−>carbohydrate ?></td><td><?= $item−>pro t e in ?></td><td><?= $item−>f a t ?></td><td><?= $item−>energy ?></td><td><?= $item−>weight as purchased ?></td><td><?= $item−>we i gh t ed i b l e po r t i on ?></td><td><a id=”editFELDialogButton” c l a s s=”editFELDialogButton” hr e f = ’ . . / home cmanager/ e d i t f e l /<?php

echo $ f o o d e x c h an g e l i s t i d ; ?>’><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Edit”><span c l a s s=”ui−i con ui−icon−pen c i l”></span></ l i ></ul></a><a h r e f =”. ./ home cmanager/ d e l e t e f e l i t em /<?php echo $ f o o d e x c h an g e l i s t i d ; ?>” onc l i c k=”

return conf irm ( ’ Are you sure you want to d e l e t e ? ’ )”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Delete”><span c l a s s=”ui−i con ui−icon−t rash”></span></ l i ></ul></a></td></tr><?php endforeach ;?><tr><?php i f ( i s s e t ( $pag inat ion ) ) {echo $pag inat ion ; } ?></tr>

126

Page 138: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

</table></center><?php } ?>

<?php i f ( i s a r r a y ( $query ht ) ) { ?><center><table><tr><th s t y l e=”d i sp l ay : none;”>ID</th><th>Health Tip</th><th>Actions</th></tr><?php fo reach ( $query ht as $item ) : ?><?php $h e a l t h t i p i d = $item−>h e a l t h t i p i d ; ?><tr><td s t y l e=”d i sp l ay : 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 id=”editHTDialogButton” c l a s s=”editHTDialogButton” h r e f = ’ . . / home cmanager/ ed i t h t /<?php

echo $h e a l t h t i p i d ; ?>’><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Edit”><span c l a s s=”ui−i con ui−icon−pen c i l”></span></ l i ></ul></a><a h r e f =”. ./ home cmanager/ d e l e t e h e a l t h t i p /<?php echo $h e a l t h t i p i d ; ?>” onc l i c k=”return

conf irm ( ’ Are you sure you want to d e l e t e ? ’ )”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Delete”><span c l a s s=”ui−i con ui−icon−t rash”></span></ l i ></ul></a></td></tr><?php endforeach ;?></table></center><?php } ?></div></div></div><p c l a s s=”f o o t e r”>Page rendered in <strong>{e l apsed t ime}</strong> seconds</p></body></html>

<?php

i f ( $use r type == ”Administrator ”) {r e d i r e c t ( ’ home admin ’ , ’ r e f r e sh ’ ) ; // r e d i r e c t to Administrator Page

}

e l s e i f ( $use r type == ”Content Manager ”) {r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ; // r e d i r e c t to Content Manager Page

}

e l s e i f ( $use r type == ”User ”) {r e d i r e c t ( ’ home user ’ , ’ r e f r e sh ’ ) ; // r e d i r e c t to Reg i s t e r ed User Page

}

?>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t>

<s c r i p t>$ ( document ) . ready ( func t i on ( ) {$(”#us−inner−nav ”) . hide ( ) ;

$ ( ” . us−top−nav ”) . mouseenter ( func t i on ( ) {$(”#us−inner−nav ”) . fadeIn ( ) ;}) ;

$ ( ” . us−top−nav ”) . mouseleave ( func t i on ( ) {$(”#us−inner−nav ”) . fadeOut ( ) ;}) ;

$(”#user−inner−nav ”) . hide ( ) ;

$ ( ” . user−top−nav ”) . mouseenter ( func t i on ( ) {$(”#user−inner−nav ”) . fadeIn ( ) ;}) ;

127

Page 139: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ ( ” . user−top−nav ”) . mouseleave ( func t i on ( ) {$(”#user−inner−nav ”) . fadeOut ( ) ;}) ;

$(”#user−user−inner−nav ”) . hide ( ) ;

$ ( ” . user−user−top−nav ”) . mouseenter ( func t i on ( ) {$(”#user−user−inner−nav ”) . fadeIn ( ) ;}) ;

$ ( ” . user−user−top−nav ”) . mouseleave ( func t i on ( ) {$(”#user−user−inner−nav ”) . fadeOut ( ) ;}) ;

$(”#user−user−user−inner−nav ”) . hide ( ) ;

$ ( ” . user−user−user−top−nav ”) . mouseenter ( func t i on ( ) {$(”#user−user−user−inner−nav ”) . fadeIn ( ) ;}) ;

$ ( ” . user−user−user−top−nav ”) . mouseleave ( func t i on ( ) {$(”#user−user−user−inner−nav ”) . fadeOut ( ) ;}) ;

$(”#user−user−user−user−inner−nav ”) . hide ( ) ;

$ ( ” . user−user−user−user−top−nav ”) . mouseenter ( func t i on ( ) {$(”#user−user−user−user−inner−nav ”) . fadeIn ( ) ;}) ;

$ ( ” . user−user−user−user−top−nav ”) . mouseleave ( func t i on ( ) {$(”#user−user−user−user−inner−nav ”) . fadeOut ( ) ;}) ;

$ ( ”#viewProf i l eBoxDia log ” ) . d i a l og ({autoOpen : f a l s e ,width : 650 ,modal : true ,closeOnEscape : f a l s e}) ;

// Link to open the d i a l og$ ( ”#viewProf i leBoxDialogButton ” ) . c l i c k ( func t i on ( event ) {$ ( ”#viewProf i l eBoxDia log ” ) . d i a l og ( ”open” ) ;event . preventDefau l t ( ) ;}) ;

$(”#success msg ”) . fadeOut (5000) ;}) ;

$ ( func t i on ( ) {$ ( ”#logoutButton , #userSearchButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

s t a r tRe f r e sh ( ) ;s t a r tRe f r e sh1 ( ) ;}) ;

/∗ var au t o r e f r e s h = s e t I n t e r v a l (func t i on ( ){$( ’#userHealthTipsBox ’ ) . fadeOut ( ’ slow ’ ) . load ( ’<?php echo s i t e u r l ( ) ; ?>/home user / u s e r h t f e ed

’ ) . f ade In (” slow ”) ;} , 10000) ;∗/

func t i on s t a r tRe f r e sh ( ) {setTimeout ( s ta r tRe f r e sh ,1000) ;$ . get ( ’<?php echo s i t e u r l ( ) ; ?>home user / u s e r h t f e ed ’ , f unc t i on ( data ) {$( ’#userHealthTipsBox ’ ) . html ( data ) ;}) ;}

f unc t i on s t a r tRe f r e sh1 ( ) {setTimeout ( s ta r tRe f r e sh1 ,1000) ;$ . get ( ’<?php echo s i t e u r l ( ) ; ?>home user / use r ach i evements f e ed ’ , f unc t i on ( data ) {$( ’#userAchievementsBox ’ ) . html ( data ) ;}) ;}</s c r i p t></head><body><div id=”conta ine r”><div id=”header”></div><div id=”body”><div id=”logoutBox”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x us−top−nav”>< l i id =”se t t ingsButton ” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”<?php echo $ f i r s t name ;

?>”>

128

Page 140: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<span c l a s s=”ui−i con ui−icon−person”></span><span c l a s s=”s e t t i ng s−person”><?php echo$ f i r s t name ; ?> (<?php echo $use r type ; ?>)</span>

<span c l a s s=”ui−i con ui−icon−t r i ang 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 id=”us−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l us−inner−nav”><div id=”viewProf i leBoxDialogButton ” c l a s s=”us−inner−nav−opt ion ” t i t l e =”P r o f i l e In format ion”><

span c l a s s=”ui−i con ui−icon−s c r i p t”></span>P r o f i l e Information</div><a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / e d i t p r o f i l e u s e r /<?php echo $username ; ?>”><div

c l a s s=”us−inner−nav−opt ion ” t i t l e =”Edit P r o f i l e”><span c l a s s=”ui−i con ui−icon−penc i l”></span>Edit P ro f i l e </div>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / ed i t pa s sword use r /<?php echo $username ; ?>”><divc l a s s=”us−inner−nav−opt ion ” t i t l e =”Change Password”><span c l a s s=”ui−i con ui−icon−gear”></span>Change Password</div>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / logout”><div c l a s s=”us−inner−nav−opt ion ” t i t l e =”Logout”><span c l a s s=”ui−i con ui−icon−key”></span>Logout</div></a>

</ l i ></ul></div>

<div id=”viewPro f i l eBoxDia log ” t i t l e =”P r o f i l e In format ion”><table><tr><td>Name :<td><?php echo $ f i r s t name ; ?> <?php echo $last name ; ?></tr><tr><td>Username :<td><?php echo $username ; ?></tr><tr><td>User Type :<td><?php echo $use r type ; ?></tr><tr><td>E−mail Address :<td><?php echo $ema i l addre s s ; ?></tr><tr><td>Gender :<td><?php echo $gender ; ?></tr><tr><td>Birthday :<td><?php echo $birthday ; ?></tr></table></div>

<div id=”userContentBox”><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><div id=”userContentHeading ” c l a s s=”ui−widget−header ui−corner−a l l ”><center><h2>&nbsp ; In format ion Board</h2></center></div>

<div id=”userFeedHeading”><center><table><tr><td width=”328.33px;”><div id=”userAchievementsViewHeading”><center><h2>&nbsp ; Achievements</h2></center></div></td>

<td width=”328.33px;”><div id=”userHealthTipsViewHeading”><center><h2>&nbsp ; Health Tips</h2></center></div></div></td></tr><table></center></div>

<div id=”userMenuBox”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x user−top−nav”>< l i id =”F i tne s sPro f i l eBut ton ” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”F i tne s s P r o f i l e ”><span c l a s s=”ui−i con ui−icon−note”></span><span c l a s s=”user−note”>Fi tne s s P r o f i l e &nbsp;</span

><span c l a s s=”ui−i con ui−icon−t r i ang l e−1−s user−t r i a n g l e”></span></ l i >< l i id=”user−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l user−inner−nav”><a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / s h ow f i t n e s s p r o f i l e”><div c l a s s=”user−inner−nav−

opt ion ” t i t l e =”View Fi tne s s P r o f i l e”><span c l a s s=”ui−i con ui−icon−s c r i p t”></span>ViewInformation</div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / a d d f i t n e s s p r o f i l e”><div c l a s s=”user−inner−nav−opt ion ” t i t l e =”Add Informat ion”><span c l a s s=”ui−i con ui−icon−p lu s th i ck”></span>AddInformation</div></a>

<!−−<div c l a s s=”user−inner−nav−opt ion ” t i t l e =”Edit In format ion”><span c l a s s=”ui−i con ui−icon−pen c i l”></span>Edit Information</div>−−>

</ l i ></ul><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x user−user−top−nav”>< l i id =”RecipesButton” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Recipes”><span c l a s s=”ui−i con ui−icon−c l i pboard”></span><span c l a s s=”user−user−c l i pboard”>&nbsp;&nbsp;&

nbsp;&nbsp;&nbsp ; Recipes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span c l a s s=”ui−i con ui−icon−t r i ang l e−1−s user−user−t r i a n g l e”></span></ l i >< l i id=”user−user−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l user−user−inner−nav”>

129

Page 141: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / add rec ipe”><div c l a s s=”user−user−inner−nav−opt ion” t i t l e =”Create Recipe”><span c l a s s=”ui−i con ui−icon−p lu s th i ck”></span>Create Recipe</div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / show c r ea t ed r e c i p e s”><div c l a s s=”user−user−inner−nav−opt ion ” t i t l e =”Created Recipes”><span c l a s s=”ui−i con ui−icon−s c r i p t”></span>CreatedRecipes</div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / p l an da i l y mea l s”><div c l a s s=”user−user−inner−nav−opt ion ” t i t l e =”Plan Dai ly Meals”><span c l a s s=”ui−i con ui−icon−l i g h tbu lb”></span>Plan Dai lyMeals</div></a>

</ l i ></ul><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x user−user−user−top−nav”>< l i id =”recommendContentButton” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Share

Achievement”><span c l a s s=”ui−i con ui−icon−s t a r”></span><span c l a s s=”user−user−user−s t a r”>Share Achievement

</span><span c l a s s=”ui−i con ui−icon−t r i ang l e−1−s user−user−user−t r i a n g l e”></span></ l i >< l i id=”user−user−user−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l user−user−user−inner−

nav”><a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / share achievement”><div c l a s s=”user−user−user−

inner−nav−opt ion ” t i t l e =”Share Achievement”><span c l a s s=”ui−i con ui−icon−l i g h tbu lb”></span>on t h i s S i te </div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / share ach i evement fb”><div c l a s s=”user−user−user−inner−nav−opt ion ” t i t l e =”Share on Facebook”><span c l a s s=”ui−i con ui−icon−l i g h tbu lb”></span>on Facebook</div></a>

<!−−<a h r e f=”<?php echo s i t e u r l ( ) ; ?>/home user / sha r e ach i evement tw i t t e r”><div c l a s s=”user−user−user−inner−nav−opt ion ” t i t l e =”Share on Twitter”><span c l a s s=”ui−i con ui−icon−l i g h tbu lb”></span>on Twitter</div></a>−−>

</ l i ></ul><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x user−user−user−user−top−nav”>< l i id =”recommendContentButton” c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Browse”><span c l a s s=”ui−i con ui−icon−search”></span><span c l a s s=”user−user−user−user−search”>&nbsp;&

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;&nbsp;</span>

<span c l a s s=”ui−i con ui−icon−t r i ang l e−1−s user−user−user−user−t r i a n g l e”></span></ l i >< l i id=”user−user−user−user−inner−nav” c l a s s=”ui−s tate−de f au l t ui−corner−a l l user−user−user−

user−inner−nav”><a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / show shared r e c ipe s”><div c l a s s=”user−user−user−

user−inner−nav−opt ion ” t i t l e =”Shared Recipes”><span c l a s s=”ui−i con ui−icon−c l i pboard”></span>Shared Recipes</div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / show recommended recipes”><div c l a s s=”user−user−user−user−inner−nav−opt ion ” t i t l e =”Recommended Recipes”><span c l a s s=”ui−i con ui−icon−c l i pboard”></span>Recommended Recipes</div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / show recommended daily meals”><div c l a s s=”user−user−user−user−inner−nav−opt ion ” t i t l e =”Recommended Dai ly Meals”><span c l a s s=”ui−i con ui−icon−c l i pboard”></span>Recommended Dai ly Meals</div></a>

<a h r e f=”<?php echo s i t e u r l ( ) ; ?>home user / s e a r c h f e l”><div c l a s s=”user−user−user−user−inner−nav−opt ion ” t i t l e =”Food Nut r i t i ona l In format ion”><span c l a s s=”ui−i con ui−icon−l i g h tbu lb”></span>Food Nut r i t i ona l Information</div></a>

</ l i ></ul></div>

<div id=”userViewBox”><center><table><tr><td width=”328.33px ; ” s t y l e=”d i sp l ay : none;”><div=”userRecipesViewBox”><div id=”userRecipesViewHeading”><center><h2>&nbsp ; Recipes</h2></center></div><div id=”userRecipesBox”></div></div></td>

<td width=”328.33px;”><div=”userAchievementsViewBox”><div id=”userAchievementsBox”></div></div></td>

<td width=”328.33px;”><div=”userHealthTipsViewBox”><div id=”userHealthTipsBox”></div></div></td></tr><table></center></div></div></div><p c l a s s=”f o o t e r”>Page rendered in <strong>{e l apsed t ime}</strong> seconds</p></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” />

130

Page 142: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></s c r i p t>

<s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom. j s ”></s c r i p t>

<s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#resetPasswordButton , #resetPasswordBackButton” ) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;}) ;</s c r i p t></head><body><div id=”conta ine r”><div id=”header”></div><div id=”body”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font></center><div id=”resetPasswordBox”><div id=”resetPasswordHeading ” c l a s s=”ui−widget−header ui−corner−a l l ”><center><h2>&nbsp ; Reset Password</h2></center></div><?php echo form open ( ’ l o g i n / doforget ’ ) ; ?><center><table><tr></tr><tr></tr><tr><td><l a b e l f o r=”ema i l addre s s”>&nbsp ; E−mail Address :</ labe l><td><input id=”ema i l addre s s ” name=”ema i l addre s s ” type=”text ” value=”<?php echo s e t v a l u e ( ’

emai l address ’ ) ; ?>”><span id=”ema i l v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><button id=”resetPasswordButton ” type=”submit” name=”submit” value=”submit”>Reset Password

</button><td><button id=”resetPasswordBackButton” type=”button” name=”resetPasswordBackButton” value=”

Back” onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?> l og in ’”>Back</button></tr><tr></tr><tr></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></div></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”shor tcut i con ” type=”image/x−i con ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images /

heas f imicon . i c o”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#loginButton , #reg i s t e rBut ton ” ) . button ( ) ;$ ( ”#userTypeRadioButtonSet , #genderRadioButtonSet ” ) . buttonset ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#b i r thdate ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true ,// t h i s opt ion f o r a l l ow ing user to s e l e c t monthchangeYear : true , // t h i s opt ion f o r a l l ow ing user to s e l e c t from year rangemaxDate : ’ 0 ’ ,dateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,

131

Page 143: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

onClose : func t i on ( ) {$( ’# birthdate ’ ) . v a l i d ( ) ;i f ( $( ’# birthdate ’ ) . va 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 echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”#b i r t h d a t e v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

b i r t h d a t e r e qu i r e d e r r o r . png ’ ) ” }) ;}}}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#username reg ”) . keyup ( func t i on ( ) {i f ( $(”#username reg ”) . va l ( ) . l ength >= 4) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?> index . php/ l o g i n / check use r ” ,data : ”name=”+$(”#username reg ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images / c o r r e c t

. png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

u s e rname ex i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e i f ( $(”#username reg ”) . va l ( ) . l ength < 4) {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

use rname l ength e r ro r . png ’ ) ” }) ;}e l s e {$(”# u s r v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”#password reg ”) . keyup ( func t i on ( ) {i f ( $(”#conf i rm password reg ”) . va l ( ) . l ength >= 8) {i f ( $(”#conf i rm password reg ”) . va l ( ) !=$(”#password reg ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}

e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}e l s e i f ( $(”#password reg ”) . va l ( ) . l ength < 8) {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

pa s sword l eng th e r ro r . png ’ ) ” }) ;}e l s e {$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” })}}) ;

$(”#conf i rm password reg ”) . keyup ( func t i on ( ) {i f ( $(”#password reg ”) . va l ( ) . l ength >=8) {i f ( $(”#conf i rm password reg ”) . va l ( ) !=$(”#password reg ”) . va l ( ) ) {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / password match error . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

password match error . png ’ ) ” }) ;pwd=f a l s e ;r e g i s t e r s how ( ) ;}e l s e {$(”#con f i rmpas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout /

images / c o r r e c t . png ’ ) ” }) ;$(”#pas sword ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;}}}) ;

$(”#ema i l addre s s ”) . keyup ( func t i on ( ) {var emai l = $(”#ema i l addre s s ”) . va l ( ) ;i f ( emai l != 0) {i f ( i sVal idEmai lAddress ( emai l ) ) {$ . ajax ({type : ”POST” ,u r l : ”<?php echo ba s e u r l ( ) ;?> index . php/ l o g i n / check emai l ” ,data : ” emai l=”+$(”#ema i l addre s s ”) . va l ( ) ,su c c e s s : func t i on (msg) {i f (msg==”true ”) {

132

Page 144: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /c o r r e c t . png ’ ) ” }) ;

emai l con=true ;r e g i s t e r s how ( ) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l e x i s t s e r r o r . png ’ ) ” }) ;}}}) ;}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

ema i l i n v a l i d e r r o r . png ’ ) ” }) ;}}e l s e {$(”# ema i l v e r i f y ”) . c s s ({ ”background−image ” : ”none” }) ;}}) ;

$(”# f i r s t name ”) . keyup ( func t i on ( ) {i f ( $( ’# f i r s t name ’ ) . va l ( ) != ’ ’ ) {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# f i r s t n ame v e r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

f i r s t n ame r e q u i r e d e r r o r . png ’ ) ” }) ;}}) ;

$(”#last name ”) . keyup ( func t i on ( ) {i f ( $( ’# last name ’ ) . va l ( ) != ’ ’ ) {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

c o r r e c t . png ’ ) ” }) ;} e l s e {$(”# la s tname ve r i f y ”) . c s s ({ ”background−image ” : ” u r l ( ’<?php echo ba s e u r l ( ) ;?> l ayout / images /

l a s t n ame r e qu i r e d e r r o r . png ’ ) ” }) ;}}) ;}) ;

f unc t i on isVal idEmai lAddress ( emailAddress ) {var pattern = new RegExp (/ˆ ( ( ” [\w−\s ]+”) | ( [ \w− ]+(? :\ . [\w−]+)∗) | ( ” [ \w−\s ]+”) ( [\w− ]+(? :\ . [\w−]+)

∗) ) (@( ( ? : [ \w−]+\.)∗\w[\w− ]{0 ,66}) \ . ( [ 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 ) ;

r e turn pattern . t e s t ( emailAddress ) ;}f unc t i on aboutModal ( ) {$(”#aboutModal ”) . d i a l og ({autoOpen : f a l s e ,modal : true ,t i t l e : ’About ’ ,width : ’ auto ’ ,he ight : ’ auto ’ ,buttons : {”Ok” : func t i on ( ) {$ ( t h i s ) . d i a l og (” c l o s e ”) ;}} ,}) . d i a l og ( ’ open ’ ) ;r e turn f a l s e ;}</s c r i p t></head><body>

<div id=”conta ine r”><div id=”header”></div>

<div id=”body”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font></center>

<div id=”loginMainBox”>

<div id=”aboutModal” s t y l e=”d i sp l ay : none;”><center>HEAS:FIM ( Healthy Eating Aler t System : Food Intake Monitor )<br>i s a system that he lps monitor f i t n e s s and c a l o r i e intake<br>towards a h e a l t h i e r l i v i n g . I t automat i ca l l y computes the<br>amount o f c a l o r i e s per s e rv ing and r e s t r i c t s c e r ta in<br>i n g r e d i e n t s based on hea l th cond i t i on s .</center></div>

<div id=”log inHeading ” c l a s s=”ui−widget−header ui−corner−a l l ”><center><h2>&nbsp ; Login</h2></center></div>

<div id=”loginBox”><br><?php echo form open ( ’ v e r i f y l o g i n ’ ) ; ?><center><table><tr></tr><tr>

133

Page 145: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<td><l a b e l f o r=”username”>Username:</ labe l><td><input id=”username” name=”username” type=”text”></tr><tr><td><l a b e l f o r=”password”>Password :</ labe l><td><input id=”password” name=”password” type=”password”></tr><tr></tr><tr><td><button id=”log inButton ” type=”submit”>Login</button><td><a h r e f=”<?php s i t e u r l ( ) ?> l o g i n / fo rge t pas sword”>Forgot password</a><a h r e f=”#” onc l i c k=” j a v a s c r i p t : aboutModal ( ) ;”>About</a></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div>

<div id=”reg i s t e rHead ing ” c l a s s=”ui−widget−header ui−corner−a l l ”><center><h2>&nbsp ; Reg i s ter </h2></center></div>

<div id=”signupBox”><br><?php echo form open ( ’ l o g i n / save ’ , array ( ’ username ’ => ’myform ’ ) ) ; ?><center><table><tr></tr><tr></tr><tr><td><l a b e l f o r=”f i r s t name”>&nbsp ; F i r s t Name:</ labe l><td><input id=”f i r s t name ” name=”f i r s t name ” type=”text ” value=”<?php echo s e t v a l u e ( ’

f i r s t name ’ ) ; ?>”><td><span id=” f i r s t n ame v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”middle name”>&nbsp ; Middle Name ( Optional ) :</ labe l><td><input id=”middle name” name=”middle name” type=”text ” value=”<?php echo s e t v a l u e ( ’

middle name ’ ) ; ?>”></tr><tr><td><l a b e l f o r=”last name”>&nbsp ; Last Name:</ labe l><td><input id=”last name ” name=”last name ” type=”text ” value=”<?php echo s e t v a l u e ( ’ last name

’ ) ; ?>”><td><span id=”l a s tname ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”b i r thdate”>&nbsp ; Birthdate :</ labe l><td><input id=”b i r thdate ” name=”b i r thdate ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value=”<?

php echo s e t v a l u e ( ’ b i r thdate ’ ) ; ?>” readonly=”readonly”><a h r e f=”#bi r thdate ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><td><span id=”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></tr><tr><td><l a b e l f o r=”gender”>&nbsp ; Gender:</ labe l><td><div id=”genderRadioButtonSet”><input type=”rad io ” id=”genderMale” name=”genderRadio ” value=”Male” <?php echo s e t r a d i o ( ’

genderRadio ’ , ’Male ’ , TRUE) ; ?>>< l a b e l f o r=”genderMale”>Male</labe l><input type=”rad io ” id=”genderFemale” name=”genderRadio ” value=”Female” <?php echo s e t r a d i o ( ’

genderRadio ’ , ’ Female ’ ) ; ?>>< l a b e l f o r=”genderFemale”>Female</labe l></div></tr>

<div id=”userTypeRadioButtonSet ” s t y l e=” v i s i b i l i t y : hidden”><input type=”rad io ” id=”userTypeUser ” name=”userTypeRadio” value=”User” checked><l a b e l f o r=”

userTypeUser”>User</labe l></div><tr><td><l a b e l f o r=”ema i l addre s s”>&nbsp ; E−mail Address :</ labe l><td><input id=”ema i l addre s s ” name=”ema i l addre s s ” type=”text ” value=”<?php echo s e t v a l u e ( ’

emai l address ’ ) ; ?>”><td><span id=”ema i l v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”username reg”>&nbsp ; Username:</ labe l><td><input id=”username reg ” name=”username reg ” type=”text ” value=”<?php echo s e t v a l u e ( ’

username reg ’ ) ; ?>” ><td><span id=”u s r v e r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”password reg”>&nbsp ; Password :</ labe l><td><input id=”password reg ” name=”password reg ” type=”password” value=”<?php echo s e t v a l u e

( ’ password reg ’ ) ; ?>” ><td><span id=”pas sword ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><l a b e l f o r=”conf i rm password reg”>&nbsp ; Confirm Password:</ labe l><td><input id=”conf i rm password reg ” name=”conf i rm password reg ” type=”password” value=”<?php

echo s e t v a l u e ( ’ conf i rm password reg ’ ) ; ?>”><td><span id=”con f i rmpas sword ve r i f y ” c l a s s=”v e r i f y”></span></tr><tr><td><td><?php echo $cap img ?></tr><tr><td>&nbsp ; Please type the code above :<td><input type=”text ” id=”captcha ” name=”captcha ” value=”” />

134

Page 146: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

</tr><tr><td><button id=”reg i s t e rBut ton ” type=”submit” name=”submit” value=”submit”>Regis ter </button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></div><p c l a s s=”f o o t e r”>Page rendered in <strong>{e l apsed t ime}</strong> seconds</p></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>

$ ( func t i on ( ) {

$ ( ”#planDailyMealsBackButton , #planDailyMealsHomeButton , #searchMealButton , #goButton” ) .button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;}}) ;

$ ( ”#planDai lyMealsDia log ” ) . d i a l og ({autoOpen : true ,width : 850 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;}) ;$ ( document ) . ready ( func t i on ( ) {$(”#success msg ”) . fadeOut (5000) ;}) ;</s c r i p t></head><body><div id=”planDai lyMealsDia log ” t i t l e =”Plan Dai ly Meals”><br><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><center><table><tr><th><h3>Add Meals to Dai ly Meal Plan</th><?php echo form open ( ’ home user / search meal ’ ) ; ?><td><button id=”searchMealButton” type=”submit” name=”submit” value=”submit”>Search Meal</

button></td><button id=”planDailyMealsBackButton” type=”button” name=”planDailyMealsBackButton” value=”

Back” onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”planDailyMealsHomeButton” type=”button” name=”planDailyMealsHomeButton” value=”

Home” onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button><?php echo f o rm c l o s e ( ) ; ?></tr><?php echo form open ( ’ home user / s e l e c t by da t e ’ ) ; ?>

<tr><th><h3>Search Dai ly Meal Plan</th><h5><th><l a b e l f o r=”reco rd date”>&nbsp ; Date:</ labe l ></th>

135

Page 147: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<td><input id=”reco rd date ” name=”reco rd date ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value=”<?php echo s e t v a l u e ( ’ r ecord date ’ ) ; ?>” readonly=”readonly”>

<a h r e f=”#reco rd date ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><button id=”goButton” type=”submit” name=”submit” value=”submit”>Go</button><tr></tr><tr></tr></tr><?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 record found ! ’ ) {echo $ r e s u l t d i s p l a y ;} e l s e { ?><tr></tr><tr></tr><tr></tr><tr></tr><tr><th><h3>Recipes</th></tr><tr><!−−<th>ID</th>−−><!−−<th>Record Date</th>−−><th>Health Condition</th><th>Meal Group</th><th>Recipe Name</th><th>Ca lo r i e s ( Kcal )</th><th>Carbohydrates ( g )</th><th>Prote in ( g )</th><th>Fat ( g )</th><th>Actions</th></tr><?php $sum ca lo r i e s = 0 ; ?><?php $sum carbohydrates = 0 ; ?><?php $sum prote in = 0 ; ?><?php $sum fat = 0 ; ?><?php fo reach ( $ r e s u l t d i s p l a y as $value ) { ?><?phpi f ( i s s e t ( $value−>c a l o r i e s ) ) {$ c a l o r i e s = $value−>c a l o r i e s ;$ sum ca lo r i e s += $ c a l o r i e s ;}?><?phpi f ( i s s e t ( $value−>carbohydrate ) ) {$carbohydrates = $value−>carbohydrate ;$sum carbohydrates += $carbohydrates ;}?><?phpi f ( i s s e t ( $value−>pro t e in ) ) {$prote in = $value−>pro t e in ;$sum prote in += $prote in ;}?><?phpi f ( i s s e t ( $value−>f a t ) ) {$ f a t = $value−>f a t ;$sum fat += $ fa t ;}?>

<?php $ c a l o r i e l i m i t = i s s e t ( $value−>c a l o r i e l i m i t ) ? $value−>c a l o r i e l i m i t : ”” ; ?><?php $ca rbohydra t e l im i t = i s s e t ( $value−>ca rbohydra t e l im i t ) ? $value−>ca rbohydra t e l im i t :

”” ; ?><?php $p r o t e i n l im i t = i s s e t ( $value−>p r o t e i n l im i t ) ? $value−>p r o t e i n l im i t : ”” ; ?><?php $ f a t l im i t = i s s e t ( $value−>f a t l i m i t ) ? $value−>f a t l i m i t : ”” ; ?><?php $hea l th cond i t i on = i s s e t ( $value−>hea l t h cond i t i on ) ? $value−>hea l t h cond i t i on : ”” ; ?><tr><!−−<td><?php $p l an da i l y mea l i d = $value−>p l an da i l y mea l i d ; echo $p l an da i l y mea l i d ; ?></

td>−−><!−−<td><?php echo $value−>r e co rd date ; ?></td>−−><!−−<td><?php $own rec ipe id = $value−>own rec ipe id ; echo $own rec ipe id ?></td>−−><?php i f ( i s s e t ( $value−>meal group ) ) : ?><td><?php i f ( i s s e t ( $value−>hea l t h cond i t i on ) ) {echo $value−>hea l t h cond i t i on ;}?></td><td><?php i f ( i s s e t ( $value−>meal group ) ) {echo $value−>meal group ;}?></td><td><?php i f ( i s s e t ( $value−>rec ipe name ) ) {echo $value−>rec ipe name ;}?></td><td><?php i f ( i s s e t ( $value−>c a l o r i e s ) ) {echo $value−>c a l o r i e s ;}?></td><td><?php i f ( i s s e t ( $value−>carbohydrate ) ) {echo $value−>carbohydrate ;}?></td><td><?php i f ( i s s e t ( $value−>pro t e in ) ) {echo $value−>pro t e in ;}?></td><td><?php i f ( i s s e t ( $value−>f a t ) ) {echo $value−>f a t ;}?></td><td><a h r e f =”. ./ home user / v i ew c r e a t ed p l an r e c i p e /<?php echo $own rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>

136

Page 148: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”><span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></a><a h r e f =”. ./ home user / de l e t e mea l /<?php echo $p l an da i l y mea l i d ; ?>” onc l i c k=”return conf irm

( ’ Are you sure you want to d e l e t e ? ’ )”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Delete”><span c l a s s=”ui−i con ui−icon−t rash”></span></ l i ></ul></a></td><?php end i f ; ?><?php } ?></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr><th><h3>Recipe Nut r i t i ona l Information</th></tr><tr><th>Total Ca lor i e s </th><th>Total Carbohydrates</th><th>Total Protein</th><th>Total Fat</th></tr><tr><td><?php echo $ sum ca lo r i e s ; ?><td><?php echo $sum carbohydrates ; ?><td><?php echo $sum prote in ; ?><td><?php echo $sum fat ; ?></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr><th><h3>Fi tne s s Information</th></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr><th>Current Health Condition</th></tr><tr><td><?php echo $hea l th cond i t i on ; ?></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr><th></th><th>Limit</th><th>Remaining</th><th>Consumed</th><th>Recommendation</th></tr><tr><td c l a s s = ”redbox”>Calo r i e<td><?php echo $ c a l o r i e l i m i t ; ?><td><?php echo $ c a l o r i e l i m i t − $ sum ca lo r i e s ; ?><td><?php echo $ sum ca lo r i e s ; ?><td><?phpi f ( ( $ c a l o r i e l i m i t − $ sum ca lo r i e s ) < 0) {echo ”< f ont c o l o r =’red ’ s i z e =’2’><b>Calo r i e Limit Exceeded !</b></font> You may want to remove

or r ep l a c e a meal with another meal o f lower c a l o r i e content . ” ;}e l s e i f ( ( $ c a l o r i e l i m i t − $ sum ca lo r i e s ) == 0 | | ( $ c a l o r i e l i m i t − $ sum ca lo r i e s ) < 10) {echo ”You are about to exceed your Ca lo r i e Limit . You may want to remove or r ep l a c e a meal

with another meal o f lower c a l o r i e content . ” ;}e l s e i f ( $ sum ca lo r i e s < $ c a l o r i e l i m i t ) {echo ”You may want to have more meals . ” ;}e l s e {echo ”−”;}?></tr><tr><td c l a s s = ”redbox”>Carbohydrate<td><?php echo $ca rbohydra t e l im i t ; ?><td><?php echo $ca rbohydra t e l im i t − $sum carbohydrates ; ?><td><?php echo $sum carbohydrates ; ?><td><?phpi f ( ( $ ca rbohydra t e l im i t − $sum carbohydrates ) < 0) {echo ”< f ont c o l o r =’red ’ s i z e =’2’><b>Carbohydrate Limit Exceeded !</b></font> You may want to

remove or r ep l a c e a meal with another meal o f lower carbohydrate content . ” ;}e l s e i f ( ( $ ca rbohydra t e l im i t − $sum carbohydrates ) == 0 | | ( $ ca rbohydra t e l im i t −

$sum carbohydrates ) < 10) {echo ”You are about to exceed your Carbohydrate Limit . You may want to remove or r ep l a c e a

meal with another meal o f lower carbohydrate content . ” ;}e l s e i f ( $sum carbohydrates < $ca rbohydra t e l im i t ) {echo ”You may want to have more meals . ” ;}e l s e {

137

Page 149: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

echo ”−”;}?></tr><tr><td c l a s s = ”redbox”>Prote in<td><?php echo $p r o t e i n l im i t ; ?><td><?php echo $p r o t e i n l im i t − $sum prote in ; ?><td><?php echo $sum prote in ; ?><td><?phpi f ( ( $ p r o t e i n l im i t − $sum prote in ) < 0) {echo ”< f ont c o l o r =’red ’ s i z e =’2’><b>Prote in Limit Exceeded !</b></font> You may want to remove

or r ep l a c e a meal with another meal o f lower pro t e in content . ” ;}e l s e i f ( ( $ p r o t e i n l im i t − $sum prote in ) == 0 | | ( $ p r o t e i n l im i t − $sum prote in ) < 10) {echo ”You are about to exceed your Prote in Limit . You may want to remove or r ep l a c e a meal

with another meal o f lower pro t e in content . ” ;}e l s e i f ( $sum prote in < $p r o t e i n l im i t ) {echo ”You may want to have more meals . ” ;}e l s e {echo ”−”;}?></tr><tr><td c l a s s = ”redbox”>Fat<td><?php echo $ f a t l im i t ; ?><td><?php echo $ f a t l im i t − $sum fat ; ?><td><?php echo $sum fat ; ?><td><?phpi f ( ( $ f a t l im i t − $sum fat ) < 0) {echo ”< f ont c o l o r =’red ’ s i z e =’2’><b>Fat Limit Exceeded !</b></font> You may want to remove or

r ep l a c e a meal with another meal o f lower f a t content . ” ;}e l s e i f ( ( $ f a t l im i t − $sum fat ) == 0 | | ( $ f a t l im i t − $sum fat ) < 10) {echo ”You are about to exceed your Fat Limit . You may want to remove or r ep l a c e a meal with

another meal o f lower f a t content . ” ;}e l s e i f ( $sum fat < $ f a t l im i t ) {echo ”You may want to have more meals . ” ;}e l s e {echo ”−”;}?></tr><?php } ?><?php } ?><?php echo f o rm c l o s e ( ) ; ?></table></center></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>

$ ( func t i on ( ) {

$ ( ”#recommendDailyMealsBackButton , #recommendDailyMealsHomeButton , #searchMealButton , #goButton” ) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,

138

Page 150: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;}}) ;$ ( ”#planDai lyMealsDia log ” ) . d i a l og ({autoOpen : true ,width : 850 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#success msg ”) . fadeOut (5000) ;}) ;</s c r i p t></head><body><div id=”planDai lyMealsDia log ” t i t l e =”Recommend Daily Meals”><br><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><center><table><tr><th><h3>Add Meals to Recommended Dai ly Meals</th><?php echo form open ( ’ home cmanager/ search meal ’ ) ; ?><td><button id=”searchMealButton” type=”submit” name=”submit” value=”submit”>Search Meal</

button></td><button id=”recommendDailyMealsBackButton” type=”button” name=”recommendDailyMealsBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Back</button>

<button id=”recommendDailyMealsHomeButton” type=”button” name=”recommendDailyMealsHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button>

<?php echo f o rm c l o s e ( ) ; ?></tr><?php echo form open ( ’ home cmanager/ s e l e c t by da t e ’ ) ; ?><tr><th><h3>Search Recommended Dai ly Meals</th><h5><th><l a b e l f o r=”reco rd date”>&nbsp ; Date:</ labe l ></th><td><input id=”reco rd date ” name=”reco rd date ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value

=”<?php echo s e t v a l u e ( ’ r ecord date ’ ) ; ?>” readonly=”readonly”><a h r e f=”#reco rd date ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><button id=”goButton” type=”submit” name=”submit” value=”submit”>Go</button><tr></tr><tr></tr></tr><?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 record found ! ’ ) {echo $ r e s u l t d i s p l a y ;} e l s e { ?><tr><th><h3>Recipes</th></tr><tr><!−−<th>ID</th>−−><!−−<th>Record Date</th>−−><th>Health Condition</th><th>Meal Group</th><th>Recipe Name</th><th>Ca lo r i e s ( Kcal )</th><th>Carbohydrates ( g )</th><th>Prote in ( g )</th><th>Fat ( g )</th><th>Actions</th></tr><?php $sum ca lo r i e s = 0 ; ?><?php $sum carbohydrates = 0 ; ?><?php $sum prote in = 0 ; ?><?php $sum fat = 0 ; ?><?php fo reach ( $ r e s u l t d i s p l a y as $value ) { ?><?phpi f ( i s s e t ( $value−>c a l o r i e s ) ) {$ c a l o r i e s = $value−>c a l o r i e s ;$ sum ca lo r i e s += $ c a l o r i e s ;}?><?phpi f ( i s s e t ( $value−>carbohydrate ) ) {$carbohydrates = $value−>carbohydrate ;$sum carbohydrates += $carbohydrates ;}?><?phpi f ( i s s e t ( $value−>pro t e in ) ) {$prote in = $value−>pro t e in ;$sum prote in += $prote in ;}?><?phpi f ( i s s e t ( $value−>f a t ) ) {$ f a t = $value−>f a t ;$sum fat += $ fa t ;}

139

Page 151: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

?><tr><!−−<td><?php $recommended dai ly meal id = $value−>recommended dai ly meal id ; echo

$recommended dai ly meal id ; ?></td>−−><!−−<td><?php $recommended rec ipe id = $value−>recommended rec ipe id ; echo

$recommended rec ipe id ; ?></td>−−><!−−<td><?php echo $value−>r e co rd date ; ?></td>−−><td><?php i f ( i s s e t ( $value−>hea l t h cond i t i on ) ) {echo $value−>hea l t h cond i t i on ;}?></td><td><?php i f ( i s s e t ( $value−>meal group ) ) {echo $value−>meal group ;}?></td><td><?php i f ( i s s e t ( $value−>rec ipe name ) ) {echo $value−>rec ipe name ;}?></td><td><?php i f ( i s s e t ( $value−>c a l o r i e s ) ) {echo $value−>c a l o r i e s ;}?></td><td><?php i f ( i s s e t ( $value−>carbohydrate ) ) {echo $value−>carbohydrate ;}?></td><td><?php i f ( i s s e t ( $value−>pro t e in ) ) {echo $value−>pro t e in ;}?></td><td><?php i f ( i s s e t ( $value−>f a t ) ) {echo $value−>f a t ;}?></td><td><a h r e f =”. ./ home cmanager/ v iew created recommended rec ipe/<?php echo $recommended rec ipe id ;

?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”><span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></a><a h r e f =”. ./ home cmanager/ de l e t e mea l /<?php echo $recommended dai ly meal id ; ?>” onc l i c k=”

return conf irm ( ’ Are you sure you want to d e l e t e ? ’ )”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Delete”><span c l a s s=”ui−i con ui−icon−t rash”></span></ l i ></ul></a></td><?php } ?></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr><th><h3>Recipe Nut r i t i ona l Information</th></tr><tr><th>Total Ca lor i e s </th><th>Total Carbohydrates</th><th>Total Protein</th><th>Total Fat</th></tr><tr><td><?php echo $ sum ca lo r i e s ; ?><td><?php echo $sum carbohydrates ; ?><td><?php echo $sum prote in ; ?><td><?php echo $sum fat ; ?></tr><?php } ?><?php } ?><?php echo f o rm c l o s e ( ) ; ?></table></center></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>

140

Page 152: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ ( func t i on ( ) {

$ ( ”#addMealBackButton , #addMealHomeButton , #addMealButton , #userSearchMealButton , #addMealButton” ) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;}}) ;

$ ( ”#addMealDialog” ) . d i a l og ({autoOpen : true ,width : 850 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;}) ;$ ( document ) . ready ( func t i on ( ) {$(”#success msg ”) . fadeOut (5000) ;}) ;</s c r i p t></head><body><div id=”addMealDialog” t i t l e =”Add Meal”><br><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><!−−<?php echo $reco rd date ; ?>−−><?=form open ( ’ home cmanager/ search meal ’ ) ;?><?php $search meal = array ( ’ name’=>’ search meal ’ , ’ id ’=>’ search meal ’ , ’ value ’=> ’ ’ ,) ; ?><center>Search f o r Recipe : <?=form input ( $search meal ) ;?><button id=”userSearchMealButton” type=”submit” value=”” t i t l e =”Search Meal”>Search</button><button id=”addMealBackButton” type=”button” name=”addMealBackButton” value=”Back” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager/ recommend daily meals ’”>Back</button>

<button id=”addMealHomeButton” type=”button” name=”addMealHomeButton” value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button>

</center><?=fo rm c l o s e ( ) ;?>

<?php i f ( i s a r r a y ( $query meal ) ) { ?><center><?php i f ( ! empty ( $query meal ) ) : ?><table><tr><th s t y l e=”d i sp l ay : none;”>ID</th><th>Health Condition</th><th>Meal Type</th><th>Recipe Name</th><th>Serv ing Size</th><th>Ca lo r i e s ( Kcal )</th><th>Carbohydrate ( g )</th><th>Prote in ( g )</th><th>Fat ( g )</th><th>Actions</th></tr><?php fo reach ( $query meal as $item ) : ?><?php $recommended rec ipe id = $item−>recommended rec ipe id ?><tr><td s t y l e=”d i sp l ay : none;”><?= $item−>recommended rec ipe id ?></td><td><?= $item−>hea l t h cond i t i on ?></td><td><?= $item−>meal type ?></td><td><?= $item−>rec ipe name ?></td><td><?= $item−>s e rv ing sugg ?></td><td><?= $item−>c a l o r i e s ?></td><td><?= $item−>carbohydrate ?></td><td><?= $item−>pro t e in ?></td><td><?= $item−>f a t ?></td><td><a h r e f =”. ./ home cmanager/ v i ew c r ea t ed r e c i p e mea l /<?php echo $recommended rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”><span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></a><a h r e f =”. ./ home cmanager/add meal/<?php echo $recommended rec ipe id ; ?>”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Add Meal”>

141

Page 153: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<span c l a s s=”ui−i con ui−icon−p lu s th i ck”></span></ l i ></ul></a></tr><?php endforeach ;?></table><?php e l s e : ?><?php echo ”No data to d i sp l ay . ” ; ?><?php end i f ; ?></center><?php } ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>

$ ( func t i on ( ) {

$ ( ”#addMealBackButton , #addMealHomeButton , #addMealButton , #userSearchMealButton , #addMealButton” ) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;}}) ;

$ ( ”#addMealDialog” ) . d i a l og ({autoOpen : true ,width : 850 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#success msg ”) . fadeOut (5000) ;}) ;</s c r i p t></head><body><div id=”addMealDialog” t i t l e =”Add Meal”><br><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><!−−<?php echo $reco rd date ; ?>−−><?=form open ( ’ home user / search meal ’ ) ;?><?php $search meal = array ( ’ name’=>’ search meal ’ , ’ id ’=>’ search meal ’ , ’ value ’=> ’ ’ ,) ; ?><center>Search f o r Recipe : <?=form input ( $search meal ) ;?><button id=”userSearchMealButton” type=”submit” value=”” t i t l e =”Search Meal”>Search</button><button id=”addMealBackButton” type=”button” name=”addMealBackButton” value=”Back” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user / p lan da i l y mea l s ’”>Back</button><button id=”addMealHomeButton” type=”button” name=”addMealHomeButton” value=”Back” onc l i c k=”

window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></center><?=fo rm c l o s e ( ) ;?>

<?php i f ( i s a r r a y ( $query meal ) ) { ?><center><?php i f ( ! empty ( $query meal ) ) : ?><table>

142

Page 154: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<tr><th s t y l e=”d i sp l ay : none;”>ID</th><th>Health Condition</th><th>Meal Type</th><th>Recipe Name</th><th>Serv ing Size</th><th>Ca lo r i e s ( Kcal )</th><th>Carbohydrate ( g )</th><th>Prote in ( g )</th><th>Fat ( g )</th><th>Actions</th></tr><?php fo reach ( $query meal as $item ) : ?><?php $own rec ipe id = $item−>own rec ipe id ?><tr><td s t y l e=”d i sp l ay : none;”><?= $item−>own rec ipe id ?></td><td><?= $item−>hea l t h cond i t i on ?></td><td><?= $item−>meal type ?></td><td><?= $item−>rec ipe name ?></td><td><?= $item−>s e rv ing sugg ?></td><td><?= $item−>c a l o r i e s ?></td><td><?= $item−>carbohydrate ?></td><td><?= $item−>pro t e in ?></td><td><?= $item−>f a t ?></td><td><a h r e f =”. ./ home user / v i ew c r ea t ed r e c i p e mea l /<?php echo $own rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”><span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></a><a h r e f =”. ./ home user /add meal/<?php echo $own rec ipe id ; ?>”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Add Meal”><span c l a s s=”ui−i con ui−icon−p lu s th i ck”></span></ l i ></ul></a></tr><?php endforeach ;?></table><?php e l s e : ?><?php echo ”No data to d i sp l ay . ” ; ?><?php end i f ; ?></center><?php } ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#userSearchFELButton , #userSearchFELBackButton , #userSearchFELHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#userSearchFELDialog ” ) . d i a l og ({autoOpen : true ,width : 925 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

</s c r i p t></head><body><div id=”userSearchFELDialog ” t i t l e =”Food Nut r i t i ona l In format ion”><br><?=form open ( ’ home user / s e a r c h f e l ’ ) ;?>

143

Page 155: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<?php $ s e a r c h f e l = array ( ’ name’=>’ s e a r c h f e l ’ , ’ id ’=>’ s e a r c h f e l ’ , ’ value ’=> ’ ’ ,) ; ?><center>Food Nut r i t i ona l In format ion : <?=form input ( $ s e a r c h f e l ) ;?><button id=”userSearchFELButton” type=”submit” value=”” t i t l e =”Search Food Nut r i t i ona l

In format ion”>Search</button><button id=”userSearchFELBackButton” type=”button” name=”userSearchFELBackButton” value=”Back”

onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”userSearchFELHomeButton” type=”button” name=”userSearchFELHomeButton” value=”Home”

onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></center><?=fo rm c l o s e ( ) ;?>

<?php i f ( i s a r r a y ( $ qu e r y f e l ) ) { ?><center><?php i f ( ! empty ( $qu e r y f e l ) ) : ?><table><tr><th>L i s t Group</th><th>Food Group</th><th>Food Group Category</th><th>Food Name</th><th>Measure</th><th>Carbohydrate ( g )</th><th>Prote in ( g )</th><th>Fat ( g )</th><th>Energy ( Kcal )</th><th>Weight as Purchased ( g )</th><th>Weight Edible Port ion ( g )</th></tr><?php fo reach ( $qu e r y f e l as $item ) : ?><tr><td><?= $item−>l i s t g r o u p ?></td><td><?= $item−>food group ?></td><td><?= $item−>f ood group category ?></td><td><?= $item−>food name ?></td><td><?= $item−>measure ?></td><td><?= $item−>carbohydrate ?></td><td><?= $item−>pro t e in ?></td><td><?= $item−>f a t ?></td><td><?= $item−>energy ?></td><td><?= $item−>weight as purchased ?></td><td><?= $item−>we i gh t ed i b l e po r t i on ?></td></tr><?php endforeach ;?></table><?php e l s e : ?><?php echo ”No data to d i sp l ay . ” ; ?><?php end i f ; ?></center><?php } ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#shareAchievementButton , #shareAchievementBackButton , #shareAchievementHomeButton ”) . button

( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#shareAchievementDialog ” ) . d i a l og ({autoOpen : true ,width : 485 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

</s c r i p t></head><body>

144

Page 156: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<div id=”shareAchievementDialog ” t i t l e =”Share Achievement”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open ( ’ home user / post facebook ’ ) ; ?><center><table><tr></tr><tr></tr><tr><td><t ex ta r ea rows=”4” c o l s =”40” id=”achievement ” name=”achievement ” type=”longtex t ” value

=”<?php echo s e t v a l u e ( ’ achievement ’ ) ; ?>”></textarea></tr><tr><td><button id=”shareAchievementButton” type=”submit” name=”submit” value=”submit”>Share

Achievement</button><button id=”shareAchievementBackButton” type=”button” name=”shareAchievementBackButton” value

=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”shareAchievementHomeButton” type=”button” name=”shareAchievementHomeButton” value

=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#shareAchievementButton , #shareAchievementBackButton , #shareAchievementHomeButton ”) . button

( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#shareAchievementDialog ” ) . d i a l og ({autoOpen : true ,width : 485 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

</s c r i p t></head><body><div id=”shareAchievementDialog ” t i t l e =”Share Achievement”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open ( ’ home user / share ach ievement save ’ ) ; ?><center><table><tr></tr><tr></tr><tr><td><t ex ta r ea rows=”4” c o l s =”40” id=”achievement ” name=”achievement ” type=”longtex t ” value

=”<?php echo s e t v a l u e ( ’ achievement ’ ) ; ?>” ></textarea></tr><tr><td><button id=”shareAchievementButton” type=”submit” name=”submit” value=”submit”>Share

Achievement</button><button id=”shareAchievementBackButton” type=”button” name=”shareAchievementBackButton” value

=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”shareAchievementHomeButton” type=”button” name=”shareAchievementHomeButton” value

=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

145

Page 157: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#shareAchievementButton , #shareAchievementBackButton , #shareAchievementHomeButton ”) . button

( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#shareAchievementDialog ” ) . d i a l og ({autoOpen : true ,width : 485 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

</s c r i p t></head><body><div id=”shareAchievementDialog ” t i t l e =”Share Achievement”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><?php echo form open ( ’ home user / po s t tw i t t e r ’ ) ; ?><center><table><tr></tr><tr></tr><tr><td><t ex ta r ea rows=”4” c o l s =”40” id=”achievement ” name=”achievement ” type=”longtex t ” value

=”<?php echo s e t v a l u e ( ’ achievement ’ ) ; ?>” ></textarea></tr><tr><td><button id=”shareAchievementButton” type=”submit” name=”submit” value=”submit”>Share

Achievement</button><td><button id=”shareAchievementBackButton” type=”button” name=”shareAchievementBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button>

<button id=”shareAchievementHomeButton” type=”button” name=”shareAchievementHomeButton” value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</tr></table></center><?php echo f o rm c l o s e ( ) ; ?></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t>

$ ( func t i on ( ) {

$ ( ”#planDailyMealsBackButton , #planDailyMealsHomeButton , #searchMealButton , #goButton” ) .button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {

146

Page 158: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#reco rd date ” ) . da tep i cke r ({c l i c k Inpu t : true ,changeMonth : true , // a l low user to s e l e c t monthchangeYear : true , // a l low user to s e l e c t from year rangedateFormat : ’ yy−mm−dd ’ ,yearRange : ”−100:+0” ,onClose : func t i on ( ) {$( ’# record date ’ ) . v a l i d ( ) ;}}) ;$ ( ”#planDai lyMealsDia log ” ) . d i a l og ({autoOpen : true ,width : 850 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”}) ;}) ;</s c r i p t></head><body><div id=”planDai lyMealsDia log ” t i t l e =”Recommended Dai ly Meals”><br><f ont c o l o r=”red ” s i z e=”2”><b><?php echo v a l i d a t i o n e r r o r s ( ) ; ?></b></font><center><table><tr><button id=”planDailyMealsBackButton” type=”button” name=”planDailyMealsBackButton” value=”

Back” onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”planDailyMealsHomeButton” type=”button” name=”planDailyMealsHomeButton” value=”

Back” onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></tr><?php echo form open ( ’ home user / recommended se lect by date ’ ) ; ?><tr><th><h3>Search Recommended Dai ly Meals</th><h5><th><l a b e l f o r=”reco rd date”>&nbsp ; Date:</ labe l ></th><td><input id=”reco rd date ” name=”reco rd date ” type=”text ” c l a s s=”date−pick dp−app l i ed ” value

=”<?php echo s e t v a l u e ( ’ r ecord date ’ ) ; ?>” readonly=”readonly”><a h r e f=”#reco rd date ” c l a s s=”dp−choose−date ” t i t l e =”Choose date”>Choose date</a><button id=”goButton” type=”submit” name=”submit” value=”submit”>Go</button><tr></tr><tr></tr></tr><?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 record found ! ’ ) {echo $ r e s u l t d i s p l a y ;} e l s e { ?><tr><th><h3>Recipes</th></tr><tr><!−−<th>ID</th>−−><!−−<th>Record Date</th>−−><th>Health Condition</th><th>Meal Group</th><th>Recipe Name</th><th>Ca lo r i e s ( Kcal )</th><th>Carbohydrates ( g )</th><th>Prote in ( g )</th><th>Fat ( g )</th><th>Actions</th></tr><?php $sum ca lo r i e s = 0 ; ?><?php $sum carbohydrates = 0 ; ?><?php $sum prote in = 0 ; ?><?php $sum fat = 0 ; ?><?php fo reach ( $ r e s u l t d i s p l a y as $value ) { ?><?phpi f ( i s s e t ( $value−>c a l o r i e s ) ) {$ c a l o r i e s = $value−>c a l o r i e s ;$ sum ca lo r i e s += $ c a l o r i e s ;}?><?phpi f ( i s s e t ( $value−>carbohydrate ) ) {$carbohydrates = $value−>carbohydrate ;$sum carbohydrates += $carbohydrates ;}?><?phpi f ( i s s e t ( $value−>pro t e in ) ) {$prote in = $value−>pro t e in ;$sum prote in += $prote in ;}?><?phpi f ( i s s e t ( $value−>f a t ) ) {$ f a t = $value−>f a t ;$sum fat += $ fa t ;}?>

147

Page 159: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<tr><!−−<td><?php $p l an da i l y mea l i d = $value−>p l an da i l y mea l i d ; echo $p l an da i l y mea l i d ; ?></

td>−−><!−−<td><?php echo $value−>r e co rd date ; ?></td>−−><!−−<td><?php $recommended rec ipe id = $value−>recommended rec ipe id ; echo

$recommended rec ipe id ?></td>−−><td><?php i f ( i s s e t ( $value−>hea l t h cond i t i on ) ) {echo $value−>hea l t h cond i t i on ;}?></td><td><?php i f ( i s s e t ( $value−>meal group ) ) {echo $value−>meal group ;}?></td><td><?php i f ( i s s e t ( $value−>rec ipe name ) ) {echo $value−>rec ipe name ;}?></td><td><?php i f ( i s s e t ( $value−>c a l o r i e s ) ) {echo $value−>c a l o r i e s ;}?></td><td><?php i f ( i s s e t ( $value−>carbohydrate ) ) {echo $value−>carbohydrate ;}?></td><td><?php i f ( i s s e t ( $value−>pro t e in ) ) {echo $value−>pro t e in ;}?></td><td><?php i f ( i s s e t ( $value−>f a t ) ) {echo $value−>f a t ;}?></td><td><a h r e f =”. ./ home user / v iew created recommended rec ipe/<?php echo $recommended rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”><span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></a></td><?php } ?></tr><tr><th><h3>Information</th></tr><tr><h5><th><l a b e l f o r=” t o t a l c a l o r i e s”>&nbsp ; Total Ca l o r i e s :</ labe l ></th><td><?php echo $ sum ca lo r i e s ; ?></tr><tr><h5><th><l a b e l f o r=”to ta l c a rbohyd ra t e s”>&nbsp ; Total Carbohydrates :</ labe l ></th><td><?php echo $sum carbohydrates ; ?></tr><tr><h5><th><l a b e l f o r=”t o t a l p r o t e i n”>&nbsp ; Total Prote in :</ labe l ></th><td><?php echo $sum prote in ; ?></tr><tr><h5><th><l a b e l f o r=” t o t a l f a t”>&nbsp ; Total Fat:</ labe l ></th><td><?php echo $sum fat ; ?></tr><?php } ?><?php } ?><?php echo f o rm c l o s e ( ) ; ?></table></center></div></body></html>

<?php i f ( i s a r r a y ( $achievement feed ) ) { ?><center>

<?php fo reach ( $achievement feed as $item ) : ?><?= $item−>achievement ?><br><br>

<?php endforeach ;?></center>

<?php } ?>

<?php i f ( i s a r r a y ( $h t f e ed ) ) { ?><center>

<?php fo reach ( $h t f e ed as $item ) : ?><?= $item−>h e a l t h t i p ?><br><br>

<?php endforeach ;?><!−−<tr>

<?php i f ( i s s e t ( $pag inat ion ) ) {echo $pag inat ion ;

} ?></tr>−−>

</center><?php } ?>

<html lang=”en”>

148

Page 160: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =”Created Recipes”><br><?php i f ( i s a r r a y ( $query ) ) { ?><center><table><tr><th>ID</th><th>Health Condition</th><th>Meal Type</th><th>Recipe Name</th><th>Serv ing Size</th><th>Total Ca l o r i e s ( Kcal )</th><th>Total Carbohydrate ( g )</th><th>Total Prote in ( g )</th><th>Total Fat ( g )</th><th>Actions</th></tr><?php fo reach ( $query as $item ) : ?><?php $own rec ipe id= $item−>own rec ipe id ?><tr><td><?= $item−>own rec ipe id ?></td></tr><?php endforeach ;?></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t>

149

Page 161: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;$ ( document ) . ready ( func t i on ( ) {$(”#success msg ”) . fadeOut (5000) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =”Created Recipes”><br><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><?php i f ( i s a r r a y ( $query ) ) { ?><center><?php i f ( ! empty ( $query ) ) : ?><table><tr><th s t y l e=”d i sp l ay : none;”>ID</th><th>Health Condition</th><th>Meal Type</th><th>Recipe Name</th><th>Serv ing Size</th><th>Total Ca l o r i e s ( Kcal )</th><th>Total Carbohydrate ( g )</th><th>Total Prote in ( g )</th><th>Total Fat ( g )</th><th>Actions</th></tr><?php fo reach ( $query as $item ) : ?><?php $recommended rec ipe id= $item−>recommended rec ipe id ?><?php $rec ipe name= $item−>rec ipe name ?><tr><td s t y l e=”d i sp l ay : none;”><?= $item−>recommended rec ipe id ?></td><td><?= $item−>hea l t h cond i t i on ?></td><td><?= $item−>meal type ?></td><td><?= $item−>rec ipe name ?></td><td><?= $item−>s e rv ing sugg ?></td><td><?= $item−>c a l o r i e s ?></td><td><?= $item−>carbohydrate ?></td><td><?= $item−>pro t e in ?></td><td><?= $item−>f a t ?></td><td><a h r e f =”. ./ home cmanager/ v i ew c r e a t ed r e c i p e /<?php echo $recommended rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”><span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></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 echo $recommended rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Edit Recipe”><span c l a s s=”ui−i con ui−icon−pen c i l”></span></ l i ></ul></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 echo $recommended rec ipe id ; ?>” onc l i c k

=”return conf irm ( ’ Are you sure you want to d e l e t e ? ’ )”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Delete”><span c l a s s=”ui−i con ui−icon−t rash”></span></ l i ></ul></a></td></tr><?php endforeach ;?></table><?php e l s e : ?><?php echo ”No data to d i sp l ay . ” ; ?><?php end i f ; ?></center><?php } ?><br>

150

Page 162: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {$(”#success msg ”) . fadeOut (5000) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =”Created Recipes”><br><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><?php i f ( i s a r r a y ( $query ) ) { ?><center><?php i f ( ! empty ( $query ) ) : ?><table><tr><th s t y l e=”d i sp l ay : none;”>ID</th><th>Health Condition</th><th>Meal Type</th><th>Recipe Name</th><th>Serv ing Size</th><th>Total Ca l o r i e s ( Kcal )</th><th>Total Carbohydrate ( g )</th><th>Total Prote in ( g )</th><th>Total Fat ( g )</th><th>Actions</th></tr><?php fo reach ( $query as $item ) : ?><?php $own rec ipe id= $item−>own rec ipe id ?><?php $rec ipe name= $item−>rec ipe name ?><tr><td s t y l e=”d i sp l ay : none;”><?= $item−>own rec ipe id ?></td><td><?= $item−>hea l t h cond i t i on ?></td><td><?= $item−>meal type ?></td><td><?= $item−>rec ipe name ?></td><td><?= $item−>s e rv ing sugg ?></td><td><?= $item−>c a l o r i e s ?></td><td><?= $item−>carbohydrate ?></td><td><?= $item−>pro t e in ?></td><td><?= $item−>f a t ?></td><td><a h r e f =”. ./ home user / v i ew c r e a t ed r e c i p e /<?php echo $own rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”>

151

Page 163: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></a><a h r e f =”. ./ home user / e d i t c r e a t e d r e c i p e /<?php echo $own rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Edit Recipe”><span c l a s s=”ui−i con ui−icon−pen c i l”></span></ l i ></ul></a><a h r e f =”. ./ home user / d e l e t e c r e a t e d r e c i p e /<?php echo $own rec ipe id ; ?>” onc l i c k=”return

conf irm ( ’ Are you sure you want to d e l e t e ? ’ )”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Delete”><span c l a s s=”ui−i con ui−icon−t rash”></span></ l i ></ul></a><a h r e f =”. ./ home user / s h a r e c r e a t e d r e c i p e /<?php echo $own rec ipe id ; ?>”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Share on S i t e”><span c l a s s=”ui−i con ui−icon−l i n k”></span></ l i ></ul></a></td></tr><?php endforeach ;?></table><?php e l s e : ?><?php echo ”No data to d i sp l ay . ” ; ?><?php end i f ; ?></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><table><tr>

152

Page 164: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr><tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $recommended rec ipe id= $item−>recommended rec ipe id ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b><td><?php $a = $query [0]−> prepara t i on procedure ; echo $a ; ?></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user /recommended se lect by date ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewFPBackButton , #viewFPHomeButton”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {

153

Page 165: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewFPDialog” ) . d i a l og ({autoOpen : true ,width : 1100 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;

$ ( document ) . ready ( func t i on ( ) {var opt ions = {chart : {renderTo : ’ weightChartBox ’ ,type : ’ l i n e ’ ,marginRight : 130 ,marginBottom : 25} ,t i t l e : {t ext : ’Weight Monitor ’ ,x : −20 // cente r} ,s u b t i t l e : {t ext : ’ ’ ,x : −20} ,xAxis : {c a t e g o r i e s : [ ]} ,yAxis : {t i t l e : {t ext : ’Weight ( kg ) ’} ,

p l o tL ine s : [{value : 0 ,width : 1 ,c o l o r : ’#808080 ’} ]} ,t o o l t i p : {/∗ f o rmatter : func t i on ( ) {re turn ’<b>’+ t h i s . s e r i e s . name +’</b><br/>’+t h i s . x + ’: ’+ t h i s . y ;}∗/va l u eSu f f i x : ’ kg ’} ,

l egend : {l ayout : ’ v e r t i c a l ’ ,a l i g n : ’ r i ght ’ ,v e r t i c a lA l i g n : ’ top ’ ,x : −10,y : 100 ,borderWidth : 0} ,

s e r i e s : [ ]}

$ . getJSON(” weightmonitor getdata ” , func t i on ( j son ) {opt ions . xAxis . c a t e g o r i e s = json [ 0 ] [ ’ data ’ ] ;opt ions . s e r i e s [ 0 ] = j son [ 1 ] ;opt ions . s e r i e s [ 1 ] = j son [ 2 ] ;// opt ions . s e r i e s [ 2 ] = j son [ 3 ] ;chart = new Highcharts . Chart ( opt ions ) ;}) ;

$(”#success msg ”) . fadeOut (5000) ;}) ;

</s c r i p t></head><body><div id=”viewFPDialog” t i t l e =”F i tne s s P r o f i l e In format ion”><br><div id =”success msg”><center><f ont c o l o r=”red ” s i z e=”2”><b><?php echo $th i s−>s e s s i on−>f l a shda ta ( ’ success msg ’ ) ;

?></b></font></center></div><?php i f ( i s a r r a y ( $query ) ) { ?><center><?php i f ( ! empty ( $query ) ) : ?><table><tr><div id=”weightChartBox” s t y l e=”min−width : 400px ; he ight : 400px ; margin : 0 auto”></div></tr><tr><th s t y l e=”d i sp l ay : none;”>ID</th><th>Current Weight ( kg )</th><th>Goal Weight ( kg )</th><th>I d ea l Weight ( kg )</th><th>Height (cm)</th>

154

Page 166: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<th>BMI</th><th>BMI C l a s s i f i c a t i o n </th><th>Nut r i t i ona l Status</th><th>Recommendation</th><th>Daily Ca lo r i e Limit ( Kcal )</th><th>Daily Carbohydrate Limit ( g )</th><th>Daily Prote in Limit ( g )</th><th>Daily Fat Limit ( g )</th><th>Health Condition</th><th>Record Date</th><th>Actions</th></tr><?php fo reach ( $query as $item ) : ?><?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 ?><tr><td s t y l e=”d i sp l ay : none;”><?= $item−>f i t n e s s i n f o i d ?></td><td><?= $item−>cur r ent we ight ?></td><td><?= $item−>goa l we ight ?></td><td><?phpi f ( $gender = ”Male ”) {i f ( ( $item−>he ight ) > 152 .4 ) {$IBW = ( ( ( ( $item−>he ight ) − 152 .4 ) ∗ (0 .3937) ) ∗ ( 2 . 3 ) ) + 50 ;echo round ($IBW) ;}e l s e {$IBW = 50 ;echo round ($IBW) ;}}e l s e {i f ( ( $item−>he ight ) > 152 .4 ) {$IBW = ( ( ( ( $item−>he ight ) − 152 .4 ) ∗ (0 .3937) ) ∗ ( 2 . 3 ) ) + 45 . 5 ;echo round ($IBW) ;}e l s e {$IBW = 45 . 5 ;echo round ($IBW) ;}}?></td><td><?= $item−>he ight ?></td><td><?= $BMI=round ( ( $item−>cur r ent we ight ) /( ( $item−>he ight /100) ∗( $item−>he ight /100) ) , 2) ?></

td><td><?phpi f ($BMI<=18.5) {echo ”Underweight ” ;} e l s e i f ( ($BMI > 18 . 5 ) && ($BMI <= 24 .9 ) ) {echo ”Normal ” ;} e l s e i f ($BMI > 24 .9 && $BMI <= 29 .9 ) {echo ”Overweight ” ;} e l s e i f ($BMI > 29 .9 && $BMI <= 39 .9 ) {echo ”Obese ” ;} e l s e {echo ” Insane ly Obese ” ;}?></td><td><?phpi f ($BMI<=18.5) {echo ”Malnourished ” ;} e l s e i f ( ($BMI > 18 . 5 ) && ($BMI <= 24 .9 ) ) {echo ”Normal ” ;} e l s e i f ($BMI > 24 .9 && $BMI <= 29 .9 ) {echo ”Overnourished ” ;} e l s e i f ($BMI > 29 .9 && $BMI <= 39 .9 ) {echo ”Very Exce s s i v e l y Nourished ” ;} e l s e {echo ”Over f lowing ly Nourished ” ;}?></td><td><?phpi f ($BMI<=18.5) {echo ”Gain Weight ” ;} e l s e i f ( ($BMI > 18 . 5 ) && ($BMI <= 24 .9 ) ) {echo ”Maintain Weight ” ;} e l s e i f ($BMI > 24 .9 && $BMI <= 29 .9 ) {echo ”Lose Weight ” ;} e l s e i f ($BMI > 29 .9 && $BMI <= 39 .9 ) {echo ”Lose Weight ” ;} e l s e {echo ”Lose Weight ” ;}?></td><td><?= $item−>c a l o r i e l i m i t ?></td><td><?= $item−>ca rbohydra t e l im i t ?></td><td><?= $item−>p r o t e i n l im i t ?></td><td><?= $item−>f a t l i m i t ?></td><td><?= $item−>hea l t h cond i t i on ?></td><td><?= date (”Y−M−d” , s t r t o t ime ( $item−>r e co rd date ) ) ; ?></td><td><a h r e f =”. ./ home user / d e l e t e f i t n e s s p r o f i l e /<?php echo $ f i t n e s s i n f o i d ; ?>” onc l i c k=”return

conf irm ( ’ Are you sure you want to d e l e t e ? ’ )”><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>

155

Page 167: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”Delete”><span c l a s s=”ui−i con ui−icon−t rash”></span></ l i ></ul></a></td></tr><?php endforeach ;?></table><?php e l s e : ?><?php echo ”No data to d i sp l ay . ” ; ?><?php end i f ; ?></center><?php } ?><br>

<button id=”viewFPBackButton” type=”button” name=”viewFPBackButton” value=”Back” onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button>

<button id=”viewFPHomeButton” type=”button” name=”viewFPHomeButton” value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><table><tr><?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr>

156

Page 168: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<tr><td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr><tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $recommended rec ipe id= $item−>recommended rec ipe id ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b><td><?php $a = $query [0]−> prepara t i on procedure ; echo wordwrap ( $a , 15 , ”<br>\n” , TRUE) ; ?></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager/search meal ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?>

157

Page 169: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<center><table><tr><?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr><tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $own rec ipe id= $item−>own rec ipe id ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b><td><?php $a = $query [0]−> prepara t i on procedure ; echo wordwrap ( $a , 15 , ”<br>\n” , TRUE) ; ?></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user / search meal’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {

158

Page 170: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><table><tr><?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr><tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $recommended rec ipe id= $item−>recommended rec ipe id ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b><td><?php $a = $query [0]−> prepara t i on procedure ; echo wordwrap ( $a , 15 , ”<br>\n” , TRUE) ; ?></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager/show crea t ed r e c ipe s ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button>

</div></body></html>

<html lang=”en”>

159

Page 171: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><table><tr><?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr><tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $own rec ipe id= $item−>own rec ipe id ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;

160

Page 172: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b></td><td><?php $a = $query [0]−> prepara t i on procedure ; echo wordwrap ( $a , 15 , ”<br>\n” , TRUE) ; ?></td

></div></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user /show crea t ed r e c ipe s ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><table><tr><?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr><tr>

161

Page 173: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr><tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $own rec ipe id= $item−>own rec ipe id ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b><td><?php $a = $query [0]−> prepara t i on procedure ; echo wordwrap ( $a , 15 , ”<br>\n” , TRUE) ; ?></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user /s e l e c t by da t e ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?><center>

162

Page 174: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<table><tr><?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr><tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $recommended rec ipe id= $item−>recommended rec ipe id ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b><td><?php $a = $query [0]−> prepara t i on procedure ; echo wordwrap ( $a , 15 , ”<br>\n” , TRUE) ; ?></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager/s e l e c t by da t e ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home cmanager ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;

163

Page 175: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><table><tr><?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr><tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $recommended rec ipe id= $item−>recommended rec ipe id ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b><td><?php $a = $query [0]−> prepara t i on procedure ; echo wordwrap ( $a , 15 , ”<br>\n” , TRUE) ; ?></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user /show recommended recipes ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head>

164

Page 176: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#userSearchRRBackButton , #userSearchRRButton , #userSearchRRHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =”Recommended Recipes”><br><?=form open ( ’ home user / s e a r ch r e c r e c ’ ) ;?><?php $ s e a r ch r e c r e c = array ( ’ name’=>’ s e a r ch r e c r e c ’ , ’ id ’=>’ s e a r ch r e c r e c ’ , ’ value ’=> ’ ’ ,) ; ?><center>Recommended Recipes : <?=form input ( $ s e a r ch r e c r e c ) ;?><button id=”userSearchRRButton” type=”submit” value=”” t i t l e =”Search Recommended Recipes”>

Search</button><button id=”userSearchRRBackButton” type=”button” name=”userSearchRRBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”userSearchRRHomeButton” type=”button” name=”userSearchRRHomeButton” value=”Home”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></center><?=fo rm c l o s e ( ) ;?>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><?php i f ( ! empty ( $query ) ) : ?><table><tr><th s t y l e=”d i sp l ay : none;”>ID</th><th>Health Condition</th><th>Meal Type</th><th>Recipe Name</th><th>Serv ing Size</th><th>Total Ca l o r i e s ( Kcal )</th><th>Total Carbohydrate ( g )</th><th>Total Prote in ( g )</th><th>Total Fat ( g )</th><th>Actions</th></tr><?php fo reach ( $query as $item ) : ?><?php $recommended rec ipe id= $item−>recommended rec ipe id ?><?php $rec ipe name= $item−>rec ipe name ?><tr><td s t y l e=”d i sp l ay : none;”><?= $item−>recommended rec ipe id ?></td><td><?= $item−>hea l t h cond i t i on ?></td><td><?= $item−>meal type ?></td><td><?= $item−>rec ipe name ?></td><td><?= $item−>s e rv ing sugg ?></td><td><?= $item−>c a l o r i e s ?></td><td><?= $item−>carbohydrate ?></td><td><?= $item−>pro t e in ?></td><td><?= $item−>f a t ?></td><td><a h r e f =”. ./ home user / view recommended recipe/<?php echo $recommended rec ipe id ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”><span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></a></td></tr><?php endforeach ;?></table><?php e l s e : ?>

165

Page 177: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<?php echo ”No data to d i sp l ay . ” ; ?><?php end i f ; ?></center><?php } ?><br></div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#viewCreatedRecipesBackButton , #viewCreatedRecipesHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =’View Recipe ’><br>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><table><tr><?php $a = $query [0]−> img name ;$b = $query [0]−> ext ;?><img a l t=”” s r c=”<?=ba s e u r l ( ) . ’ uploads / ’ . $a . ’ . ’ . $b;?>” he ight=”250” width=”250”></tr><tr><td c l a s s = ”redbox”><b>Recipe Name:</b><td><?php $a = $query [0]−> rec ipe name ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Serv ing S i z e :</b><td><?php $a = $query [0]−> s e rv ing sugg ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Meal Type:</b><td><?php $a = $query [0]−>meal type ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Health Condit ion :</b><td><?php $a = $query [0]−> hea l t h cond i t i on ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Ca l o r i e s ( Kcal ) :</b><td><?php $a = $query [0]−> c a l o r i e s ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Carbohydrates ( g ) :</b><td><?php $a = $query [0]−> carbohydrate ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Prote in ( g ) :</b><td><?php $a = $query [0]−> pro t e in ; echo $a ; ?></tr><tr><td c l a s s = ”redbox”><b>Total Fat ( g ) :</b><td><?php $a = $query [0]−> f a t ; echo $a ; ?></tr>

166

Page 178: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<tr><th>Ingred i ent s </th><th>Measure ( g )</th></tr><?php fo reach ( $query as $item ) : ?><?php $ sh 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 ?><tr><td><?= $item−>food name ?></td><td><?php $b= $item−>measure ;$c= $item−>s e r v i n g s i z e ;echo $b∗$c ;?></td></tr><?php endforeach ;?><tr><td c l a s s = ”redbox”><b>Procedure :</b><td><?php $a = $query [0]−> prepara t i on procedure ; echo wordwrap ( $a , 15 , ”<br>\n” , TRUE) ; ?></tr></table></center><?php } ?><br><button id=”viewCreatedRecipesBackButton” type=”button” name=”viewCreatedRecipesBackButton”

value=”Back” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user /show shared rec ipe s ’”>Back</button>

<button id=”viewCreatedRecipesHomeButton” type=”button” name=”viewCreatedRecipesHomeButton”value=”Home” onc l i c k=”window . l o c a t i on . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button>

</div></body></html>

<html lang=”en”><head><meta char s e t=”utf−8”><t i t l e >Healthy Eating Aler t System</ t i t l e ><l i n k r e l=”icon ” type=”image/ i c o ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / images / heas f imicon . i c o

”><l i n k r e l=”s t y l e s h e e t ” type=”text / c s s ” h r e f=”<?php echo ba s e u r l ( ) ;?> l ayout / 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 echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ c s s /

b l i t z e r / jquery−ui −1 .10 .3 . custom . c s s ” /><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery −1 .9 . 1 . j s ”></

s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ;?> l ayout / jquery−ui −1 .10 .3 . custom/ j s / jquery−ui −1 .10 .3 . custom

. j s ”></s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery−va l ida t i on −1.11.1/ d i s t / jquery . 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 echo ba s e u r l ( ) ; ?>va l i d a t i on / jquery −1 .11 .0 .min . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / h ighchar t s . j s ”</ s c r i p t><s c r i p t s r c=”<?php echo ba s e u r l ( ) ; ?>chart / export ing . j s ”</ s c r i p t><s c r i p t>$ ( func t i on ( ) {$ ( ”#userSearchRRBackButton , #userSearchRRButton , #userSearchRRHomeButton ”) . button ( ) ;

// Hover s t a t e s on the s t a t i c widgets$ ( ”#icons l i ” ) . hover (func t i on ( ) {$ ( t h i s ) . addClass ( ”ui−s tate−hover ” ) ;} ,f unc t i on ( ) {$ ( t h i s ) . removeClass ( ”ui−s tate−hover ” ) ;}) ;

$ ( ”#viewCreatedRecipesDia log ” ) . d i a l og ({autoOpen : true ,width : 950 ,modal : true ,closeOnEscape : f a l s e ,b e f o r e c l o s e : func t i on ( event , u i ) { re turn f a l s e ; } ,d i a l ogC la s s : ” noc l o s e ”

}) ;}) ;</s c r i p t></head><body><div id=”viewCreatedRecipesDia log ” t i t l e =”Shared Recipes”><br><?=form open ( ’ home user / sea rch sharedrec ’ ) ;?><?php $s ea r ch sha r ed r e c = array ( ’ name’=>’ s ea r ch sharedrec ’ , ’ id ’=>’ s ea r ch sharedrec ’ , ’ value

’=> ’ ’ ,) ; ?><center>Shared Recipes : <?=form input ( $ s ea r ch sha r ed r e c ) ;?><button id=”userSearchRRButton” type=”submit” value=”” t i t l e =”Search Shared Recipes”>Search</

button><button id=”userSearchRRBackButton” type=”button” name=”userSearchRRBackButton” value=”Back”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Back</button><button id=”userSearchRRHomeButton” type=”button” name=”userSearchRRHomeButton” value=”Home”

onc l i c k=”window . l o c a t i o n . h r e f=’<?php echo s i t e u r l ( ) ; ?>home user ’”>Home</button></center><?=fo rm c l o s e ( ) ;?>

<?php i f ( i s a r r a y ( $query ) ) { ?><center><?php i f ( ! empty ( $query ) ) : ?><table><tr>

167

Page 179: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

<th s t y l e=”d i sp l ay : none;”>ID</th><th>Health Condition</th><th>Meal Type</th><th>Recipe Name</th><th>Serv ing Size</th><th>Total Ca l o r i e s ( Kcal )</th><th>Total Carbohydrate ( g )</th><th>Total Prote in ( g )</th><th>Total Fat ( g )</th><th>Actions</th></tr><?php fo reach ( $query as $item ) : ?><?php $ sh 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 $rec ipe name= $item−>rec ipe name ?><tr><td s t y l e=”d i sp l ay : none;”><?= $item−>s h a r e d r e c i p e i d ?></td><td><?= $item−>hea l t h cond i t i on ?></td><td><?= $item−>meal type ?></td><td><?= $item−>rec ipe name ?></td><td><?= $item−>s e rv ing sugg ?></td><td><?= $item−>c a l o r i e s ?></td><td><?= $item−>carbohydrate ?></td><td><?= $item−>pro t e in ?></td><td><?= $item−>f a t ?></td><td><a h r e f =”. ./ home user / v i ew sha r ed r e c i p e /<?php echo $ s h a r e d r e c i p e i d ; ?>” ><ul id=”i cons ” c l a s s=”ui−widget ui−helper−c l e a r f i x ”>< l i c l a s s=”ui−s tate−de f au l t ui−corner−a l l ” t i t l e =”View Recipe”><span c l a s s=”ui−i con ui−icon−f o l d e r−open”></span></ l i ></ul></a></td></tr><?php endforeach ;?></table><?php e l s e : ?><?php echo ”No data to d i sp l ay . ” ; ?><?php end i f ; ?></center><?php } ?><br></div></body></html>

B. Source Code

B..1 Configs

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| AUTO−LOADER| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| This f i l e s p e c i f i e s which systems should be loaded by de f au l t .|| In order to keep the framework as l i gh t−weight as p o s s i b l e only the| abso lute minimal r e s ou r c e s are loaded by de f au l t . For example ,| the database i s not connected to automat i ca l ly s i n c e no assumption| i s made regard ing whether you intend to use 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 systems you would l i k e loaded with every| r eques t .|| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| I n s t r u c t i o n s| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| These are the th ings you can load automat i ca l ly :|| 1 . Packages| 2 . L i b r a r i e s| 3 . Helper f i l e s| 4 . Custom con f i g f i l e s| 5 . Language f i l e s| 6 . Models|∗/

/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Auto−load Packges| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Prototype :|| $autoload [ ’ packages ’ ] = array (APPPATH. ’ th i rd par ty ’ , ’/ usr / l o c a l / shared ’ ) ;|∗/

$autoload [ ’ packages ’ ] = array ( ) ;

/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Auto−load L i b r a r i e s

168

Page 180: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| These are the c l a s s e s l o ca t ed in the system/ l i b r a r i e s f o l d e r| or in your app l i c a t i on / l i b r a r i e s f o l d e r .|| Prototype :|| $autoload [ ’ l i b r a r i e s ’ ] = array ( ’ database ’ , ’ s e s s i on ’ , ’ xmlrpc ’ ) ;∗/

$autoload [ ’ l i b r a r i e s ’ ] = array ( ’ database ’ , ’ s e s s i on ’ , ’ facebook ’ ) ;

/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Auto−load Helper F i l e s| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Prototype :|| $autoload [ ’ he lper ’ ] = array ( ’ ur l ’ , ’ f i l e ’ ) ;∗/

$autoload [ ’ he lper ’ ] = array ( ’ html ’ , ’ form ’ , ’ ur l ’ , ’ f i l e ’ ) ;

/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Auto−load Config f i l e s| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Prototype :|| $autoload [ ’ con f ig ’ ] = array ( ’ conf ig1 ’ , ’ con f ig2 ’ ) ;|| NOTE: This item i s intended f o r use ONLY i f you have created custom| c on f i g f i l e s . Otherwise , l eave i t blank .|∗/

$autoload [ ’ con f ig ’ ] = array ( ) ;

/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Auto−load Language f i l e s| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Prototype :|| $autoload [ ’ language ’ ] = array ( ’ lang1 ’ , ’ lang2 ’ ) ;|| NOTE: Do not inc lude the ” l ang ” part o f your f i l e . For example| ” c od e i g n i t e r l a n g . php” would be r e f e r en c ed as array ( ’ c ode i gn i t e r ’ ) ;|∗/

$autoload [ ’ language ’ ] = array ( ) ;

/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Auto−load Models| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Prototype :|| $autoload [ ’ model ’ ] = array ( ’ model1 ’ , ’model2 ’ ) ;|∗/

$autoload [ ’ model ’ ] = array ( ) ;

/∗ End o f f i l e autoload . php ∗//∗ Locat ion : . / app l i c a t i on / con f i g / autoload . php ∗/

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Base S i t e URL|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| URL to your CodeIgn i ter root . Typ ica l ly t h i s w i l l be your base URL,| WITH a t r a i l i n g s l a sh :|| http :// example . com/|| I f t h i s i s not s e t then CodeIgn i ter w i l l guess the protoco l , domain and| path to your i n s t a l l a t i o n .|∗/$con f i g [ ’ ba se ur l ’ ] = ’ https :// a g i l a .upm. edu . ph/˜ pjd izon /FIM/ ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Index F i l e|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| Typica l ly t h i s w i l l be your index . php f i l e , un l e s s you ’ ve renamed i t to| something e l s e . I f you are us ing mod rewrite to remove the page s e t t h i s| va r i ab l e so that i t i s blank .

169

Page 181: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

|∗/$con f i g [ ’ index page ’ ] = ’ ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| URI PROTOCOL|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| This item determines which s e rv e r g l oba l should be used to r e t r i e v e the| URI s t r i n g . The de f au 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 your l i n k s do not seem to work , t ry one o f the other d e l i c i o u s f l a v o r s :|| ’AUTO’ Defau l t − auto de t e c t s| ’PATH INFO’ Uses the PATH INFO| ’QUERY STRING’ Uses the QUERY STRING| ’REQUEST URI’ Uses the REQUEST URI| ’ORIG PATH INFO’ Uses the ORIG PATH INFO|∗/$con f i g [ ’ u r i p r o t o c o l ’ ] = ’AUTO’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| URL s u f f i x|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| This opt ion a l l ows you to add a s u f f i x to a l l URLs generated by CodeIgn i ter .| For more in format ion p l ea s e see the user guide :|| http :// c od e i g n i t e r . com/ use r gu ide / gene ra l / u r l s . html∗/

$con f i g [ ’ u r l s u f f i x ’ ] = ’ ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Defaul t Language|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| This determines which s e t o f language f i l e s should be used . Make sure| there i s an ava i l a b l e t r a n s l a t i o n i f you intend to use something other| than eng l i s h .|∗/$con f i g [ ’ language ’ ] = ’ eng l i sh ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Defaul t Character Set|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| This determines which charac t e r s e t i s used by de f au l t in var i ous methods| that r equ i r e a charac t e r s e t to be provided .|∗/$con f i g [ ’ charset ’ ] = ’UTF−8 ’;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Enable/Disab le System Hooks|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| I f you would l i k e to use the ’ hooks ’ f e a tu r e you must enable i t by| s e t t i n g t h i s v a r i ab l e to TRUE ( boolean ) . See the user guide f o r d e t a i l s .|∗/$con f i g [ ’ enable hooks ’ ] = FALSE;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Class Extension Pre f i x|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| This item a l l ows you to s e t the f i l ename / classname p r e f i x when extending| nat ive l i b r a r i e s . For more in format ion p l ea s e see the user guide :|| http :// c od e i g n i t e r . com/ use r gu ide / gene ra l / c o r e c l a s s e s . html| http :// c od e i g n i t e r . com/ use r gu ide / gene ra l / c r e a t i n g l i b r a r i e s . html|∗/$con f i g [ ’ s ub c l a s s p r e f i x ’ ] = ’MY ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Allowed URL Characters|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| This l e t s you s p e c i f y with a r egu l a r expr e s s i on which cha rac t e r s are permitted| within your URLs . When someone t r i e s to submit a URL with d i sa l l owed| cha ra c t e r s they w i l l get a warning message .|| As a s e cu r i t y measure you are STRONGLY encouraged to r e s t r i c t URLs to| as few cha rac t e r s as p o s s i b l e . By de f au l t only these are a l lowed : a−z 0−9˜%.: −|| Leave blank to a l low a l l cha ra c t e r s −− but only i f you are insane .|

170

Page 182: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS ! !|∗/$con f i g [ ’ p e rm i t t ed ur i cha r s ’ ] = ’ a−z 0−9˜%.: \− ’;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Enable Query S t r i ng s|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| By de f au l t CodeIgn i ter uses search−engine f r i e n d l y segment based URLs :| example . com/who/what/where/|| By de f au l t CodeIgn i ter enab le s a c c e s s to the $ GET array . I f f o r some| reason you would l i k e to d i s ab l e i t , s e t ’ a l l ow ge t a r r ay ’ to FALSE.|| You can op t i ona l l y enable standard query s t r i n g based URLs :| example . com?who=me&what=something&where=here|| Options are : TRUE or FALSE ( boolean )|| The other items l e t you s e t the query s t r i n g ’ words ’ that w i l l| invoke your c o n t r o l l e r s and i t s f unc t i on s :| example . com/ index . php?c=c o n t r o l l e r&m=funct i on|| Please note that some o f the he lp e r s won ’ t work as expected when| t h i s f e a tu r e i s enabled , s i n c e CodeIgn i ter i s des igned pr imar i l y to| use segment based URLs .|∗/$con f i g [ ’ a l l ow ge t a r r ay ’ ] = TRUE;$con f i g [ ’ e nab l e que ry s t r i ng s ’ ] = FALSE;$con f i g [ ’ c o n t r o l l e r t r i g g e r ’ ] = ’ c ’ ;$ con f i g [ ’ f u n c t i o n t r i g g e r ’ ] = ’m’ ;$ con f i g [ ’ d i r e c t o r y t r i g g e r ’ ] = ’d ’ ; // exper imenta l not cu r r en t l y in use

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Error Logging Threshold|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| I f you have enabled e r r o r logg ing , you can s e t an e r r o r th re sho ld to| determine what ge t s logged . Threshold opt ions are :| You can enable e r r o r l ogg ing by s e t t i n g a thre sho ld over zero . The| th r e sho ld determines what ge t s logged . Threshold opt ions are :|| 0 = Disab l e s logg ing , Error l ogg ing TURNED OFF| 1 = Error Messages ( i n c l ud ing PHP e r r o r s )| 2 = Debug Messages| 3 = In fo rmat iona l Messages| 4 = Al l Messages|| For a l i v e s i t e you ’ l l u sua l l y only enable Errors (1 ) to be logged otherwi se| your log f i l e s w i l l f i l l up very f a s t .|∗/$con f i g [ ’ l o g th r e sho ld ’ ] = 0 ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Error Logging Direc tory Path|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| Leave t h i s BLANK un l e s s you would l i k e to s e t something other than the de f au l t| app l i c a t i on / l o g s / f o l d e r . Use a f u l l s e r v e r path with t r a i l i n g s l a sh .|∗/$con f i g [ ’ log path ’ ] = ’ ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Date Format f o r Logs|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| Each item that i s logged has an a s s o c i a t ed date . You can use PHP date| codes to s e t your own date formatt ing|∗/$con f i g [ ’ l og date fo rmat ’ ] = ’Y−m−d H: i : s ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Cache Direc tory Path|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| Leave t h i s BLANK un l e s s you would l i k e to s e t something other than the de f au l t| system/ cache / f o l d e r . Use a f u l l s e r v e r path with t r a i l i n g s l a sh .|∗/$con f i g [ ’ cache path ’ ] = ’ ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Encryption Key|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| I f you use the Encryption c l a s s or the Se s s i on c l a s s you| MUST se t an encrypt ion key . See the user guide f o r i n f o .

171

Page 183: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

|∗/$con f i g [ ’ encrypt ion key ’ ] = ’REALLY LONG NUMBER’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Ses s i on Var iab l e s|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| ’ s e s s cook ie name ’ = the name you want f o r the cook i e| ’ s e s s e xp i r a t i o n ’ = the number o f SECONDS you want the s e s s i o n to l a s t .| by de f au l t s e s s i o n s l a s t 7200 seconds ( two hours ) . Set to zero f o r no exp i r a t i on .| ’ s e s s e x p i r e o n c l o s e ’ = Whether to cause the s e s s i o n to exp i r e automat i ca l ly| when the browser window i s c l o s ed| ’ s e s s en c ryp t c ook i e ’ = Whether to encrypt the cook i e| ’ s e s s u s e da taba s e ’ = Whether to save the s e s s i o n data to a database| ’ s e s s tab le name ’ = The name o f the s e s s i o n database tab l e| ’ s e s s match ip ’ = Whether to match the user ’ s IP address when read ing

the s e s s i o n data| ’ s e s s match useragent ’ = Whether to match the User Agent when read ing the s e s s i o n

data| ’ s e s s t ime to update ’ = how many seconds between CI r e f r e s h i n g Se s s i on Informat ion|∗/$con f i g [ ’ s e s s cook ie name ’ ] = ’ c i s e s s i o n ’ ;$ con f i g [ ’ s e s s e xp i r a t i o n ’ ] = 7200;$ con f i g [ ’ s e s s e x p i r e o n c l o s e ’ ] = FALSE;$con f i g [ ’ s e s s en c ryp t c ook i e ’ ] = FALSE;$con f i g [ ’ s e s s u s e da taba s e ’ ] = FALSE;$con f i g [ ’ s e s s tab le name ’ ] = ’ c i s e s s i o n s ’ ;$ con f i g [ ’ s e s s match ip ’ ] = FALSE;$con f i g [ ’ s e s s match useragent ’ ] = TRUE;$con f i g [ ’ s e s s t ime to update ’ ] = 300 ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Cookie Related Var iab l e s|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| ’ c o ok i e p r e f i x ’ = Set a p r e f i x i f you need to avoid c o l l i s i o n s| ’ cookie domain ’ = Set to . your−domain . com f o r s i t e−wide cook i e s| ’ cook ie path ’ = Typica l ly w i l l be a forward s l a sh| ’ c ook i e s e cu r e ’ = Cookies w i l l only be s e t i f a s ecure HTTPS connect ion e x i s t s .|∗/$con f i g [ ’ c o ok i e p r e f i x ’ ] = ”” ;$ con f i g [ ’ cookie domain ’ ] = ”” ;$ con f i g [ ’ cookie path ’ ] = ”/” ;$ con f i g [ ’ c ook i e s e cu r e ’ ] = FALSE;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Global XSS F i l t e r i n g|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| Determines whether the XSS f i l t e r i s always a c t i v e when GET, POST or| COOKIE data i s encountered|∗/$con 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|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Enables a CSRF cook i e token to be s e t . When s e t to TRUE, token w i l l be| checked on a submitted form . I f you are accept ing user data , i t i s s t r ong l y| recommended CSRF pro t e c t i on be enabled .|| ’ c s r f token name ’ = The token name| ’ c s r f cook i e name ’ = The cook i e name| ’ c s r f e x p i r e ’ = The number in seconds the token should exp i r e .∗/$con f i g [ ’ c s r f p r o t e c t i o n ’ ] = FALSE;$con f i g [ ’ csr f token name ’ ] = ’ c s r f t e s t name ’ ;$ con f i g [ ’ c s r f cook i e name ’ ] = ’ c s r f cook i e name ’ ;$ con f i g [ ’ c s r f e x p i r e ’ ] = 7200 ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Output Compression|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| Enables Gzip output compress ion f o r f a s t e r page loads . When enabled ,| the output c l a s s w i l l t e s t whether your s e r v e r supports Gzip .| Even i f i t does , however , not a l l browsers support compress ion| so enable only i f you are reasonably sure your v i s i t o r s can handle i t .|| VERY IMPORTANT: I f you are g e t t i ng a blank page when compress ion i s enabled i t| means you are prematurely outputt ing something to your browser . I t could| even be a l i n e o f whitespace at the end o f one o f your s c r i p t s . For| compress ion to work , nothing can be sent be f o r e the output bu f f e r i s c a l l e d| by the output c l a s s . Do not ’ echo ’ any va lues with compress ion enabled .|∗/$con f i g [ ’ compress output ’ ] = FALSE;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

172

Page 184: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

| Master Time Reference|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| Options are ’ l o c a l ’ or ’gmt ’ . This p r e f t e l l s the system whether to use| your server ’ s l o c a l time as the master ’now ’ r e f e r enc e , or convert i t to| GMT. See the ’ date he lper ’ page o f the user guide f o r in format ion| r egard ing date handl ing .|∗/$con f i g [ ’ t ime r e f e r enc e ’ ] = ’ l o ca l ’ ;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Rewrite PHP Short Tags|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| I f your PHP i n s t a l l a t i o n does not have short tag support enabled CI| can r ewr i t e the tags on−the−f l y , enab l ing you to u t i l i z e that syntax| in your view f i l e s . Options are TRUE or FALSE ( boolean )|∗/$con f i g [ ’ r ew r i t e s h o r t t a g s ’ ] = FALSE;

/∗|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| Reverse Proxy IPs|−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| I f your s e r v e r i s behind a r ev e r s e proxy , you must wh i t e l i s t the proxy IP| addre s s e s from which CodeIgn i ter should t ru s t the HTTP X FORWARDED FOR| header in order to proper ly i d e n t i f y the v i s i t o r ’ s IP address .| Comma−de l imited , e . g . ’ 1 0 . 0 . 1 . 2 0 0 , 1 0 . 0 . 1 . 2 0 1 ’|∗/$con f i g [ ’ proxy ips ’ ] = ’ ’ ;

/∗ End o f f i l e c on f i g . php ∗//∗ Locat ion : . / app l i c a t i on / con f i g / con f i g . php ∗/

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| DATABASE CONNECTIVITY SETTINGS| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| This f i l e w i l l conta in the s e t t i n g s needed to acc e s s your database .|| For complete i n s t r u c t i o n s p l e a s e consu l t the ’ Database Connection ’| page o f the User Guide .|| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| EXPLANATION OF VARIABLES| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| [ ’ hostname ’ ] The hostname o f your database s e r v e r .| [ ’ username ’ ] The username used to connect to the database| [ ’ password ’ ] The password used to connect to the database| [ ’ database ’ ] The name o f the database you want to connect to| [ ’ dbdriver ’ ] The database type . i e : mysql . Current ly supported :

mysql , mysqli , postgre , odbc , mssql , s q l i t e , o c i 8| [ ’ dbpre f ix ’ ] You can add an opt i ona l p r e f i x , which w i l l be added| to the tab l e name when us ing the Active Record c l a s s| [ ’ pconnect ’ ] TRUE/FALSE − Whether to use a p e r s i s t e n t connect ion| [ ’ db debug ’ ] TRUE/FALSE − Whether database e r r o r s should be d i sp layed .| [ ’ cache on ’ ] TRUE/FALSE − Enables / d i s a b l e s query caching| [ ’ cachedir ’ ] The path to the f o l d e r where cache f i l e s should be s to red| [ ’ char s e t ’ ] The charac t e r s e t used in communicating with the database| [ ’ dbco l l a t ’ ] The charac t e r c o l l a t i o n used in communicating with the database| NOTE: For MySQL and MySQLi databases , t h i s s e t t i n g i s only

used| as a backup i f your s e r v e r i s running PHP < 5 . 2 . 3 or MySQL <

5 . 0 . 7| ( and in tab l e c r e a t i on que r i e s made with DB Forge ) .| There i s an i n c ompa t i b i l i t y in PHP with

my sq l r e a l e s c ap e s t r i n g ( ) which| can make your s i t e vu lne rab l e to SQL i n j e c t i o n i f you are

us ing a| multi−byte charac t e r s e t and are running ve r s i on s lower than

these .| S i t e s us ing Latin−1 or UTF−8 database charac t e r s e t and

c o l l a t i o n are una f f e c t ed .| [ ’ swap pre ’ ] A de f au l t t ab l e p r e f i x that should be swapped with the dbpre f i x| [ ’ au to in i t ’ ] Whether or not to automat i ca l ly i n i t i a l i z e the database .| [ ’ s t r i c t on ’ ] TRUE/FALSE − f o r c e s ’ S t r i c t Mode ’ connect ions| − good f o r ensur ing s t r i c t SQL whi le

deve lop ing|| The $ac t ive g roup va r i ab l e l e t s you choose which connect ion group to| make ac t i v e . By de f au l t there i s only one group ( the ’ de fau l t ’ group ) .|| The $a c t i v e r e c o rd va r i a b l e s l e t s you determine whether or not to load| the a c t i v e record c l a s s∗/

$ac t ive g roup = ’ de fau l t ’ ;$ a c t i v e r e c o rd = TRUE;

173

Page 185: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$db [ ’ de fau l t ’ ] [ ’ hostname ’ ] = ’ l o ca l ho s t ’ ; //hostname i s l o c a l h o s t$db [ ’ de fau l t ’ ] [ ’ username ’ ] = ’ FoodIntakeMon ’ ; //username i s root$db [ ’ de fau l t ’ ] [ ’ password ’ ] = ’pnUvqYprynEdNyZn ’ ; //no password$db [ ’ de fau l t ’ ] [ ’ database ’ ] = ’ FoodIntakeMon ’ ; // database i s fim$db [ ’ de fau l t ’ ] [ ’ dbdriver ’ ] = ’mysql ’ ;$db [ ’ de fau l t ’ ] [ ’ dbpre f ix ’ ] = ’ ’ ;$db [ ’ de fau l t ’ ] [ ’ pconnect ’ ] = TRUE;$db [ ’ de fau l t ’ ] [ ’ db debug ’ ] = TRUE;$db [ ’ de fau l t ’ ] [ ’ cache on ’ ] = FALSE;$db [ ’ de fau l t ’ ] [ ’ cachedir ’ ] = ’ ’ ;$db [ ’ de fau l t ’ ] [ ’ char s e t ’ ] = ’ utf8 ’ ;$db [ ’ de fau l t ’ ] [ ’ dbco l l a t ’ ] = ’ u t f 8 g e n e r a l c i ’ ;$db [ ’ de fau l t ’ ] [ ’ swap pre ’ ] = ’ ’ ;$db [ ’ de fau l t ’ ] [ ’ au to in i t ’ ] = TRUE;$db [ ’ de fau l t ’ ] [ ’ s t r i c t on ’ ] = FALSE;

/∗ End o f f i l e database . php ∗//∗ Locat ion : . / app l i c a t i on / con f i g / database . php ∗/

<?php/∗ $con f i g = array (

’ appId ’ => ’411694662300964 ’ ,’ s e c r e t ’ => ’4449887 dcad9b56c0e8dbc66bf63b331 ’

) ;∗//∗ $con f i g [ ’ appId ’ ] = ’411694662300964 ’ ;$ con f i g [ ’ s e c r e t ’ ] = ’4449887 dcad9b56c0e8dbc66bf63b331 ’ ; ∗ /$con f i g [ ’ appId ’ ] = ’593833454087083 ’ ;$ con f i g [ ’ s e c r e t ’ ] = ’ a9a92c6d827ae7ed0503f689141d2b05 ’ ;?>

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;/∗| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| URI ROUTING| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| This f i l e l e t s you re−map URI r eque s t s to s p e c i f i c c o n t r o l l e r f unc t i on s .|| Typica l ly there 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 corresponding c o n t r o l l e r c l a s s /method . The segments in a| URL normally f o l l ow th i s pattern :|| example . com/ c l a s s /method/ id /|| In some ins tances , however , you may want to remap th i s r e l a t i o n s h i p| so that a d i f f e r e n t c l a s s / func t i on i s c a l l e d than the one| corresponding to the URL.|| Please see the user guide f o r complete d e t a i l s :|| http :// c od e i g n i t e r . com/ use r gu ide / gene ra l / rout ing . html|| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−| RESERVED ROUTES| −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−|| There area two re s e rved route s :|| $route [ ’ d e f a u l t c o n t r o l l e r ’ ] = ’welcome ’ ;|| This route 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 should be loaded i f the| URI conta ins no data . In the above example , the ”welcome” c l a s s| would be loaded .|| $route [ ’ 404 ove r r i d e ’ ] = ’ e r r o r s / page miss ing ’ ;|| This route w i l l t e l l the Router what URI segments to use i f those provided| in the URL cannot be matched to a va l i d route .|∗/

$route [ ’ 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 au l t page l o g i n . php c o n t r o l l e r l i nked tol o g i n i nd ex . php view

$route [ ’ MY Pagination / ( : any ) ’ ] = ’ l o g i n / index ’ ;$route [ ’ 404 ove r r i d e ’ ] = ’ ’ ;

// $ 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 = array ( ’ v e r i f y l o g i n ’ , ’ logout ’ , ’ home ’ , ’ home user ’ , ’ home admin ’ , ’

home cmanager ’ ) ;

// $route [ ’ 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 ;// $route [ ” ˆ ( ( ? ! \ b ” . implode ( ’\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 ’ ;// $route [ ’ 404 ove r r i d e ’ ] = ’ ’ ;// $route [ ’ s h ow f i t n e s s p r o f i l e ’ ] = ’ home user / s h ow f i t n e s s p r o f i l e ’ ;// $route [ ’ weightmonitor getdata ’ ] = ’ home user /weightmonitor getdata ’ ;

/∗ End o f f i l e route s . php ∗//∗ Locat ion : . / app l i c a t i on / con f i g / route s . php ∗/

<?php$con f i g [ ’ tweet consumer key ’ ] = ”Y9wHRf3wQOAd5KLaW5LRwqiu2” ;$ con f i g [ ’ tweet consumer secret ’ ] = ”vchyOy5I2lyJUaqBmkqkFUzXSsuf4ayrMeioxkghag958LkDBI

” ;

174

Page 186: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

?>

B..2 Controllers

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;s e s s i o n s t a r t ( ) ; //we need to c a l l PHP’ s s e s s i o n ob j e c t to ac c e s s i t through CI

c l a s s Home extends CI Cont ro l l e r {

f unc t i on c on s t r u c t ( ) {parent : : c o n s t r u c t ( ) ;

}

f unc t i on index ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$ th i s−>load−>view ( ’ home index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

}

?>

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;s e s s i o n s t a r t ( ) ; //we need to c a l l PHP’ s s e s s i o n ob j e c t to ac c e s s i t through CI

c l a s s Home Admin extends CI Cont ro l l e r {f unc t i on c on s t r u c t ( ) {

parent : : c o n s t r u c t ( ) ;$ th i s−>load−>model ( ’ home admin model ’ ) ;

}

//INDEXfunc t i on index ( ) {

$th i s−>load−>model ( ’ home admin model ’ ) ;$data [ ’ query ’ ] = ”” ;// $th i s−>load−>vars ( $data ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ u s e r id ’ ] = $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ home admin index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//LOGOUTfunct i on logout ( ) {

$th i s−>s e s s i on−>unse t use rdata ( ’ l ogged in ’ ) ;s e s s i o n d e s t r o y ( ) ;r e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

//USER SEARCH CONTROLLERSfunc t i on sugge s t i on s ( ) {

$th i s−>load−>model ( ’ home admin model ’ ) ;$term = $th i s−>input−>post ( ’ term ’ ,TRUE) ;

i f ( s t r l e n ( $term ) < 1) break ;

$rows = $th i s−>home admin model−>GetAutocomplete ( array ( ’ keyword ’ => $term ) ) ;

$ j s on a r r ay = array ( ) ;f o r each ( $rows as $row )array push ( $ j son ar ray , $row−>use r id , $row−>username , $row−>f i r s t name , $row

−>middle name , $row−>last name , $row−>user type , $row−>emai l address , $row−>gender , $row−>birthday ) ;

echo j son encode ( $ j s on a r r ay ) ;}

f unc t i on search ( ) {

$th i s−>load−>model ( ’ home admin model ’ ) ;

$data [ ’ query ’ ] = $th i s−>home admin model−>ge t s e a r ch ( ) ;

// $data [ ’ query ’ ] = $th i s−>home admin model−>ge t s e a r ch ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

175

Page 187: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

$ th i s−>load−>view ( ’ home admin index ’ , $data ) ;}

}

//ADD USER CONTROLLERSfunc t i on add user ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}$th i s−>load−>view ( ’ add user index ’ ) ;

}

f unc t i on save ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ username ’ , ’Username ’ , ’ tr im | r equ i r ed |

alpha numeric | min length [ 4 ] | x s s c l e an | c a l l b a c k ch e c k u s e r c i ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ tr im |

r equ i r ed | alpha numeric | min length [ 8 ] ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ conf irm password ’ , ’ Confirm

Password ’ , ’ tr im | r equ i r ed | alpha numeric |matches [ password ] ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ f i r s t name ’ , ’ F i r s t Name’ , ’ tr im |

r equ i r ed | alpha numeric | xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ middle name ’ , ’ Middle Name’ , ’

a lpha numeric | xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ last name ’ , ’ Last Name’ , ’ tr im |

r equ i r ed | alpha numeric | xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ b i r thdate ’ , ’ Birthdate ’ , ’

r equ i r ed | xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ genderRadio ’ , ’Gender ’ , ’ requ i red

’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ userTypeRadio ’ , ’ User Type ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ emai l address ’ , ’ Email Address ’ ,

’ r equ i r ed | va l i d ema i l | c a l l b a ck ch e ck ema i l c i ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;$ th i s−>load−>view ( ’ add user index ’ ) ;

}e l s e {

$th i s−>load−>model ( ’ home admin model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home admin model−>proce s s ( ) ;// $message = ”Reg i s t r a t i on Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home admin ”) ;//</ s c r i p t > ’ ;//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Reg i s t r a t i on

Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home admin ’ , ’ r e f r e sh ’ ) ;

}}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

pub l i c func t i on ch e c k u s e r c i ( ) {$usr=$th i s−>input−>post ( ’ username ’ ) ;$ r e s u l t=$th i s−>home admin model−>c h e c k u s e r e x i s t ( $usr ) ;i f ( $ r e s u l t ) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Username a l readye x i s t s . ’ ) ;

r e turn f a l s e ;}e l s e {

re turn true ;}

}

pub l i c func t i on check use r ( ) {$usr=$th i s−>input−>post ( ’ name ’ ) ;$ r e s u l t=$th i s−>home admin model−>c h e c k u s e r e x i s t ( $usr ) ;i f ( $ r e s u l t ) {

echo ” f a l s e ” ;}e l s e {

echo ” true ” ;

176

Page 188: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}}

pub l i c func t i on ch e ck ema i l c i ( ) {$eml=$th i s−>input−>post ( ’ emai l address ’ ) ;$ r e s u l t=$th i s−>home admin model−>ch e c k ema i l e x i s t ( $eml ) ;i f ( $ r e s u l t ) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’E−mail Addressa l ready r e g i s t e r e d . ’ ) ;

r e turn f a l s e ;}e l s e {

re turn true ;}

}

pub l i c func t i on check emai l ( ) {$eml=$th i s−>input−>post ( ’ email ’ ) ;$ r e s u l t=$th i s−>home admin model−>ch e c k ema i l e x i s t ( $eml ) ;i f ( $ r e s u l t ) {

echo ” f a l s e ” ;}e l s e {

echo ” true ” ;}

}

//DELETE USER CONTROLLERfunc t i on d e l e t e u s e r ( $username ) {

$th i s−>home admin model−>d e l u s e r ( $username ) ;// $message = ”User was s u c c e s f u l l y de l e t ed ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home admin ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ User was s u c c e s s f u l l y

de l e t ed . ’ ) ;r e d i r e c t ( ’ home admin ’ , ’ r e f r e sh ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//EDIT USER CONTROLLERfunc t i on e d i t u s e r ( $username ) {$item = $th i s−>home admin model−>g e t u s e r ( $username ) ;$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ username ’ , ’Username ’ , ’ tr im | r equ i r ed |

min length [ 4 ] | xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ f i r s t name ’ , ’ F i r s t Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ middle name ’ , ’ Middle Name’ , ’ x s s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ last name ’ , ’ Last Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ b i r thdate ’ , ’ Birthdate ’ , ’ r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ genderRadio ’ , ’Gender ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ userTypeRadio ’ , ’ User Type ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ emai l address ’ , ’ Email Address ’ , ’ r equ i r ed |

va l id ema i l ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

’ username ’ => $th i s−>input−>post ( ’ username ’ ) ,’ f i r s t name ’ => $th i s−>input−>post ( ’ f i r s t name ’ ) ,’ middle name ’ => $th i s−>input−>post ( ’ middle name ’ ) ,’ last name ’ => $th i s−>input−>post ( ’ last name ’ ) ,’ gender ’ => $th i s−>input−>post ( ’ genderRadio ’ ) ,’ user type ’ => $th i s−>input−>post ( ’ userTypeRadio ’ ) ,’ emai l address ’ => $th i s−>input−>post ( ’ emai l address ’ ) ,’ birthday ’ => $th i s−>input−>post ( ’ b i r thdate ’ ) ,’ s tatus ’ => $th i s−>input−>post ( ’ statusRadio ’ )

) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ home admin model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home admin model−>upda t e p r o f i l e ( $username ,$data ) ;

// $message = ”Update User Su c c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . / home admin ”) ;

//</ s c r i p t > ’ ;//}

$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’Update User Su c c e s s f u l . ’ ) ;

r e d i r e c t ( ’ home admin ’ , ’ r e f r e sh ’ ) ;}

177

Page 189: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}}$data [ ’ item ’ ] = $item ;$data [ ’ username ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ username ’ , $item [ ’

username ’ ] ) ;$data [ ’ f i r s t name ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ f i r s t name ’ , $item [ ’

f i r s t name ’ ] ) ;$data [ ’ middle name ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ middle name ’ , $item

[ ’ middle name ’ ] ) ;$data [ ’ last name ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ last name ’ , $item [ ’

last name ’ ] ) ;$data [ ’ birthday ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ b i r thdate ’ , $item [ ’

birthday ’ ] ) ;$data [ ’ gender ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ genderRadio ’ , $item [ ’

gender ’ ] ) ;$data [ ’ user type ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ userTypeRadio ’ , $item

[ ’ user type ’ ] ) ;$data [ ’ emai l address ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ emai l address ’ ,

$item [ ’ emai l address ’ ] ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ ed i t u s e r i nd ex ’ , $data ) ;

}

//EDIT PROFILE CONTROLLERfunc t i on e d i t p r o f i l e u s e r ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ username ’ , ’Username ’ , ’ tr im | r equ i r ed |

min length [ 4 ] | xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ f i r s t name ’ , ’ F i r s t Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ middle name ’ , ’ Middle Name’ , ’ x s s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ last name ’ , ’ Last Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ b i r thdate ’ , ’ Birthdate ’ , ’ r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ genderRadio ’ , ’Gender ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ userTypeRadio ’ , ’ User Type ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ emai l address ’ , ’ Email Address ’ , ’ r equ i r ed |

va l id ema i l ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

’ username ’ => $th i s−>input−>post ( ’ username ’ ) ,’ f i r s t name ’ => $th i s−>input−>post ( ’ f i r s t name ’ ) ,’ middle name ’ => $th i s−>input−>post ( ’ middle name ’ ) ,’ last name ’ => $th i s−>input−>post ( ’ last name ’ ) ,’ gender ’ => $th i s−>input−>post ( ’ genderRadio ’ ) ,’ user type ’ => $th i s−>input−>post ( ’ userTypeRadio ’ ) ,’ emai l address ’ => $th i s−>input−>post ( ’ emai l address ’ ) ,’ birthday ’ => $th i s−>input−>post ( ’ b i r thdate ’ )

) ;

$username = $th i s−>input−>post ( ’ username ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>s e s s i on−>s e t u s e rda t a ( ’ l ogged in ’ , $data ) ;$th i s−>load−>model ( ’ home admin model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home admin model−>upda t e p r o f i l e ( $username ,$data ) ;

// $message = ” P r o f i l e Update Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . /

home admin ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

P r o f i l e Update Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home admin ’ , ’ r e f r e sh ’ ) ;

}}

}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ middle name ’ ] = $ s e s s i on da t a [ ’ middle name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

}e l s e {

178

Page 190: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ ed i t p r o f i l e adm in i nd ex ’ , $data ) ;}

//EDIT PASSWORD CONTROLLERfunc t i on ed i t pa s sword use r ( ) {

$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ old password ’ , ’Old Password ’ , ’ tr im |

r equ i r ed | min length [ 8 ] | ca l lback check o ld pas sword ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ tr im | r equ i r ed |

min length [ 8 ] ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ conf irm password ’ , ’ Confirm Password ’ , ’

tr im | r equ i r ed |matches [ password ] ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

’ password ’ => MD5( $th i s−>input−>post ( ’ password ’ ) ) ,’ conf irm password ’ => MD5( $th i s−>input−>post ( ’ conf irm password

’ ) )) ;

$username = $th i s−>input−>post ( ’ username ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ home admin model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home admin model−>update password ( $username ,$data ) ;

// $message = ”Password Change Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . /

home admin ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

Password Change Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home admin ’ , ’ r e f r e sh ’ ) ;

}}

}

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ ed it password admin index ’ , $data ) ;}

pub l i c func t i on check o ld password ( ) {$opwd=MD5( $th i s−>input−>post ( ’ old password ’ ) ) ;$ r e s u l t=$th i s−>home admin model−>che ck o ld pa s swo rd ex i s t ($opwd) ;i f ( $ r e s u l t ) {

re turn true ;}e l s e {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’ I n c o r r e c t OldPassword . ’ ) ;

r e turn f a l s e ;}

}}

?>

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;s e s s i o n s t a r t ( ) ; //we need to c a l l PHP’ s s e s s i o n ob j e c t to ac c e s s i t through CI

c l a s s Home Cmanager extends CI Cont ro l l e r {

f unc t i on c on s t r u c t ( ) {parent : : c o n s t r u c t ( ) ;$ th i s−>load−>he lpe r ( array ( ’ form ’ , ’ ur l ’ ) ) ;$ th i s−>load−>model ( ’ home cmanager model ’ ) ;

}

f unc t i on index ( ) {$th i s−>load−>model ( ’ home cmanager model ’ ) ;$data [ ’ que ry f e l ’ ] = ”” ;$data [ ’ query ht ’ ] = ”” ;i f ( $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ u s e r id ’ ] = $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;

179

Page 191: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ home cmanager index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//LOGOUTfunct i on logout ( ) {

$th i s−>s e s s i on−>unse t use rdata ( ’ l ogged in ’ ) ;s e s s i o n d e s t r o y ( ) ;r e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

pub l i c func t i on check use r ( ) {$usr=$th i s−>input−>post ( ’ name ’ ) ;$ r e s u l t=$th i s−>home cmanager model−>c h e c k u s e r e x i s t ( $usr ) ;i f ( $ r e s u l t ) {

echo ” f a l s e ” ;}e l s e {

echo ” true ” ;}

}

pub l i c func t i on check emai l ( ) {$eml=$th i s−>input−>post ( ’ email ’ ) ;$ r e s u l t=$th i s−>home cmanager model−>ch e c k ema i l e x i s t ( $eml ) ;i f ( $ r e s u l t ) {

echo ” f a l s e ” ;}e l s e {

echo ” true ” ;}

}

//EDIT PROFILE CONTROLLERfunc t i on e d i t p r o f i l e u s e r ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ username ’ , ’Username ’ , ’ tr im | r equ i r ed |

min length [ 4 ] | xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ f i r s t name ’ , ’ F i r s t Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ middle name ’ , ’ Middle Name’ , ’ x s s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ last name ’ , ’ Last Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ b i r thdate ’ , ’ Birthdate ’ , ’ r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ genderRadio ’ , ’Gender ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ userTypeRadio ’ , ’ User Type ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ emai l address ’ , ’ Email Address ’ , ’ r equ i r ed |

va l id ema i l ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

’ username ’ => $th i s−>input−>post ( ’ username ’ ) ,’ f i r s t name ’ => $th i s−>input−>post ( ’ f i r s t name ’ ) ,’ middle name ’ => $th i s−>input−>post ( ’ middle name ’ ) ,’ last name ’ => $th i s−>input−>post ( ’ last name ’ ) ,’ gender ’ => $th i s−>input−>post ( ’ genderRadio ’ ) ,’ user type ’ => $th i s−>input−>post ( ’ userTypeRadio ’ ) ,’ emai l address ’ => $th i s−>input−>post ( ’ emai l address ’ ) ,’ birthday ’ => $th i s−>input−>post ( ’ b i r thdate ’ )

) ;

$username = $th i s−>input−>post ( ’ username ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>s e s s i on−>s e t u s e rda t a ( ’ l ogged in ’ , $data ) ;$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home cmanager model−>upda t e p r o f i l e ( $username ,$data ) ;

// $message = ” P r o f i l e Update Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . /

home cmanager ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

P r o f i l e Update Suc e s s f u l . ’ ) ;r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;

}}

}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;

180

Page 192: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ middle name ’ ] = $ s e s s i on da t a [ ’ middle name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ ed i t p r o f i l e cmanage r i ndex ’ , $data ) ;}

//EDIT PASSWORD CONTROLLERfunc t i on ed i t pa s sword use r ( ) {

$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ old password ’ , ’Old Password ’ , ’ tr im |

r equ i r ed | min length [ 8 ] | ca l lback check o ld pas sword ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ tr im | r equ i r ed |

min length [ 8 ] ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ conf irm password ’ , ’ Confirm Password ’ , ’

tr im | r equ i r ed |matches [ password ] ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

’ password ’ => MD5( $th i s−>input−>post ( ’ password ’ ) ) ,’ conf irm password ’ => MD5( $th i s−>input−>post ( ’ conf irm password

’ ) )) ;

$username = $th i s−>input−>post ( ’ username ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home cmanager model−>update password ( $username ,$data ) ;

// $message = ”Password Change Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . /

home cmanager ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

Password Change Suc e s s f u l . ’ ) ;r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;

}}

}

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ ed it password cmanager index ’ , $data ) ;}

pub l i c func t i on check o ld password ( ) {$opwd=MD5( $th i s−>input−>post ( ’ old password ’ ) ) ;$ r e s u l t=$th i s−>home cmanager model−>che ck o ld pa s swo rd ex i s t ($opwd) ;i f ( $ r e s u l t ) {

re turn true ;}e l s e {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’ I n c o r r e c t OldPassword . ’ ) ;

r e turn f a l s e ;}

}

//ADD FOOD EXCHANGE LIST CONTROLLERSfunc t i on c h e c k f e l i t em e x i s t s ( ) {

$food name = $th i s−>input−>post ( ’ food name ’ ) ;$ r e s u l t=$th i s−>home cmanager model−>c h e c k f e l i t em e x i s t ( $food name ) ;i f ( $ r e s u l t ) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Food Itemal ready e x i s t s . ’ ) ;

r e turn f a l s e ;}e l s e {

re turn true ;}

}

f unc t i on add f e l i t em ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;

181

Page 193: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ lg ’ ] = $th i s−>home cmanager model−>g e t l i s t g r o u p ( ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}$th i s−>load−>view ( ’ add f ood exchange l i s t i ndex ’ , $data ) ;

}

pub l i c func t i on buildDropFEL ( ) {$th i s−>load−>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 oup = $th i s−>input−>post ( ’ l i s t g r oup ’ ,TRUE) ;

// run the query f o r the food group we s p e c i f i e d e a r l i e r$fgData [ ’ fgDrop ’ ]= $th i s−>home cmanager model−>ge t f ood group ( $ l i g r oup ) ;

$output = nu l l ;

f o r each ( $fgData [ ’ fgDrop ’]−> r e s u l t ( ) as $row ){// here we bu i ld a dropdown item l i n e f o r each query r e s u l t$output .= ”<opt ion value = ’”. $row−>l i s t g r o u p .” ’ >”. $row−>food group .”</ option >”;

}

echo $output ;}

pub l i c func t i on buildDropFEL2 ( ) {$th i s−>load−>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 oup = $th i s−>input−>post ( ’ l i s t g r oup ’ ,TRUE) ;

// run the query f o r the food group we s p e c i f i e d e a r l i e r$fgcData [ ’ fgcDrop ’ ]= $th i s−>home cmanager model−>ge t f ood g roup ca t ego ry ( $ l i g r oup ) ;

$output = nu l l ;

f o r each ( $fgcData [ ’ fgcDrop ’]−> r e s u l t ( ) as $row ){// here we bu i ld a dropdown item l i n e f o r each query r e s u l t$output .= ”<opt ion value = ’”. $row−>l i s t g r o u p .” ’ >”. $row−>f ood group category .”</

option >”;}

echo $output ;}

f unc t i on add f e l i t em save ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ l i s t g r oup ’ , ’ L i s t Group ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ food group ’ , ’ Food Group ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ food group category ’ , ’ Food Group Category ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ food name ’ , ’ Food Name’ , ’ r equ i r ed |c a l l b a c k c h e c k f e l i t em ex i s t s ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ measure ’ , ’Measure ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ carbohydrate ’ , ’ Carbohydrate ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ prote in ’ , ’ Protein ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ fat ’ , ’ Fat ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ energy ’ , ’ Energy ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ we ight as purchased ’ , ’Weight as Purchased ’

, ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ we i gh t ed ib l e po r t i on ’ , ’Weight Edible

Portion ’ , ’ r equ i r ed | numeric ’ ) ;

// echo ’<ore > ’ ;// p r i n t r ($ POST) ;

// echo ’</pre > ’ ;// d i e ( ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;$ th i s−>load−>view ( ’ add f ood exchange l i s t i ndex ’ ) ;

}e l s e {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home cmanager model−>p r o c e s s f e l i t em ( ) ;// $message = ”Adding o f Food Exchange L i s t Item Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home cmanager ”) ;//</ s c r i p t > ’ ;//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Adding o f Food

Exchange L i s t Item Suc e s s f u l . ’ ) ;r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;

}}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

182

Page 194: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}

//DELETE FEL ITEMfunct i on d e l e t e f e l i t em ( $ f o o d e x c h an g e l i s t i d ) {

$th i s−>home cmanager model−>d e l f e l i t em ( $ f o o d e x c h an g e l i s t i d ) ;// $message = ”Food Exchange L i s t Item was s u c c e s f u l l y de l e t ed ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home cmanager ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Food Exchange L i s t Item

was s u c c e s s f u l l y de l e t ed . ’ ) ;r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//ADD HEALTH TIP CONTROLLERSfunc t i on add hea l th t ip ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}$th i s−>load−>view ( ’ add hea l th t ip index ’ ) ;

}

f unc t i on add hea l th t i p save ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ h ea l th t i p ’ , ’ Health Tip ’ , ’ r equ i red ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;$ th i s−>load−>view ( ’ add hea l th t ip index ’ ) ;

}e l s e {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home cmanager model−>p r o c e s s h e a l t h t i p ( ) ;// $message = ”Adding o f Health Tip Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home cmanager ”) ;//</ s c r i p t > ’ ;//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Adding o f Health

Tip Suc e s s f u l . ’ ) ;r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;

}}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//DELETE HEALTH TIPfunc t i on d e l e t e h e a l t h t i p ( $ h e a l t h t i p i d ) {

$th 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 ) ;// $message = ”Health Tip was s u c c e s f u l l y de l e t ed ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home cmanager ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Health Tip was

s u c c e s s f u l l y de l e t ed . ’ ) ;r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

f unc t i on s e a r c h f e l ( ) {$th i s−>load−>model ( ’ home cmanager model ’ ) ;

$data [ ’ que ry f e l ’ ] = $th i s−>home cmanager model−>g e t s e a r c h f e l ( ) ;

$data [ ’ query ht ’ ] = ”” ;

183

Page 195: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

$ th i s−>load−>view ( ’ home cmanager index ’ , $data ) ;}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

f unc t i on s ea r ch ht ( ) {$th i s−>load−>model ( ’ home cmanager model ’ ) ;

$data [ ’ query ht ’ ] = $th i s−>home cmanager model−>g e t s e a r ch h t ( ) ;$data [ ’ que ry f e l ’ ] = ”” ;i f ( $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

$ th i s−>load−>view ( ’ home cmanager index ’ , $data ) ;}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW CREATED RECIPESfunc t i on show c r ea t ed r e c i p e s ( ) {

$data [ ’ query ’ ]= $th i s−>home cmanager model−>p r o c e s s v i ew c r e a t e d r e c i p e s ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v i ew crea t ed rec ipe s cmanage r index ’ , $data ) ; ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//EDIT CREATED RECIPESfunc t i on e d i t c r e a t e d r e c i p e ( $recommended rec ipe id ) {$item = $th i s−>home cmanager model−>g e t c r e a t e d r e c i p e ( $recommended rec ipe id ) ;$ th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s// $th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ own rec ipe id ’ , ’Username ’ , ’ tr im |

r equ i r ed | min length [ 4 ] | xs s c l ean ’ ) ;// $th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ u s e r id ’ , ’ F i r s t Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ h ea l th cond i t i on ’ , ’ Health Condition ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ meal type ’ , ’Meal Type ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ recipe name ’ , ’ Recipe Name’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ s e rv ing sugg ’ , ’ Serv ing Size ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ i ng r ed i en t s ’ , ’ Ing red i ent s ’ , ’

c a l l b a c k h e a l t h c o n d i t i o n s r e s t r i c t i o n s ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ preparat ion procedure ’ , ’ Procedure ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ c a l o r i e s ’ , ’ Ca lo r i e s ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ carbohydrate ’ , ’ Carbohydrates ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ prote in ’ , ’ Protein ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ fat ’ , ’ Fat ’ , ’ r equ i r ed | numeric ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

// ’ own rec ipe id ’ => $th i s−>input−>post ( ’ own rec ipe id ’ ) ,// ’ u s e r id ’ => $th i s−>input−>post ( ’ u s e r id ’ ) ,// ’ hea l th cond i t i on ’ => $th i s−>input−>post ( ’ h ea l th cond i t i on ’ )

,’ h ea l th cond i t i on ’ => implode (” ,” , $th i s−>input−>post ( ’

h ea l th cond i t i on ’ ) ) ,’ meal type ’ => $th i s−>input−>post ( ’ meal type ’ ) ,’ recipe name ’ => $th i s−>input−>post ( ’ recipe name ’ ) ,’ s e rv ing sugg ’ => $th i s−>input−>post ( ’ s e rv ing sugg ’ ) ,’ p reparat ion procedure ’ => $th i s−>input−>post ( ’

preparat ion procedure ’ ) ,’ c a l o r i e s ’ => $th i s−>input−>post ( ’ c a l o r i e s ’ ) ,’ carbohydrate ’ => $th i s−>input−>post ( ’ carbohydrate ’ ) ,’ prote in ’ => $th i s−>input−>post ( ’ prote in ’ ) ,

184

Page 196: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

’ fat ’ => $th i s−>input−>post ( ’ fat ’ )) ;

$data2 = array ( ) ;

$data2 [ ’ food name ’ ] = $th i s−>input−>post ( ’ i ng r ed i en t s ’ ) ;$data2 [ ’ food group ’ ] = $th i s−>input−>post ( ’ food group ’ ) ;$data2 [ ’ measure ’ ] = $th i s−>input−>post ( ’ ingred ient measure ’ ) ;$data2 [ ’ s e r v i n g s i z e ’ ] = $th i s−>input−>post ( ’ i ng r ed i en t quant i t y ’ ) ;$data2 [ ’ i n g r ed i en t i d ’ ] = $th i s−>input−>post ( ’ i n g r ed i en t i d ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home cmanager model−>update r e c ipe ($recommended recipe id , $data , $data2 ) ;

// $message = ”Edit Recipe Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . / home cmanager ”)

;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

Edit Recipe Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;

}}

}$data [ ’ item ’ ] = $item ;// $data [ ’ own rec ipe id ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ own rec ipe id ’ ,

$item [ ’ own rec ipe id ’ ] ) ;// $data [ ’ u s e r id ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ u s e r id ’ , $item [ ’

u s e r id ’ ] ) ;// $data [ ’ h ea l th cond i t i on ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’

hea l th cond i t i on ’ , $item [ ’ hea l th cond i t i on ’ ] ) ;// $data [ ’ meal type ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ meal type ’ , $item [ ’

meal type ’ ] ) ;// $data [ ’ recipe name ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ recipe name ’ ,

$item [ ’ recipe name ’ ] ) ;// $data [ ’ s e rv ing sugg ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ s e rv ing sugg ’ ,

$item [ ’ s e rv ing sugg ’ ] ) ;

// $data [ ’ food name ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ i ng r ed i en t s ’ , $item[ ’ food name ’ ] ) ;

// $data [ ’ food group ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ food group ’ , $item[ ’ food group ’ ] ) ;

// $data [ ’ measure ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ ingred ient measure ’ ,$item [ ’ measure ’ ] ) ;

// $data [ ’ s e r v i n g s i z e ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’i ng r ed i en t quant i t y ’ , $item [ ’ s e r v i n g s i z e ’ ] ) ;

// $data [ ’ preparat ion procedure ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’preparat ion procedure ’ , $item [ ’ preparat ion procedure ’ ] ) ;

// $data [ ’ c a l o r i e s ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ c a l o r i e s ’ , $item [ ’c a l o r i e s ’ ] ) ;

// $data [ ’ carbohydrate ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ carbohydrate ’ ,$item [ ’ carbohydrate ’ ] ) ;

// $data [ ’ prote in ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ prote in ’ , $item [ ’prote in ’ ] ) ;

// $data [ ’ fat ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ fat ’ , $item [ ’ fat ’ ] ) ;

// p r i n t r ( $item ) ;// d i e ( ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}$th i s−>load−>view ( ’ ed i t r e c ipe cmanage r index ’ , $data ) ;

}

//VIEW SELECTED RECIPEfunc t i on v i ew c r e a t ed r e c i p e ( $recommended rec ipe id ) {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;$data [ ’ query ’ ] = $th i s−>home cmanager model−>g e t r e c i p e c on t e n t s (

$recommended rec ipe id ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v iew rec ipe cmanager index ’ , $data ) ;

}

185

Page 197: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

e l s e {// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//DELETE CREATED RECIPEfunc t i on d e l e t e c r e a t e d r e c i p e ( $recommended rec ipe id ) {

$th i s−>home cmanager model−>d e l c r e a t e d r e c i p e ( $recommended rec ipe id ) ;// $message = ”Recipe was s u c c e s f u l l y de l e t ed ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / show c r ea t ed r e c i p e s ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Recipe was s u c c e s s f u l l y

de l e t ed . ’ ) ;r e d i r e c t ( ’ home cmanager/ show crea t ed r e c ipe s

’ , ’ r e f r e sh ’ ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//DELETE INGREDIENTSfunc t i on d e l e t e i n g r e d i e n t ( ) {

$th i s−>home cmanager model−>d e l i n g r e d i e n t ( $th i s−>input−>post ( ’ i n g r ed i en t i d ’ )) ;

}

//CREATE RECIPE CONTROLLERfunc t i on add rec ipe ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ add rec ipe cmanager index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

f unc t i on add r e c i p e s ave ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ h ea l th cond i t i on ’ , ’ Health Condition ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ meal type ’ , ’Meal Type ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ recipe name ’ , ’ Recipe Name’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ s e rv ing sugg ’ , ’ Serv ing Size ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ i ng r ed i en t s ’ , ’ Ing red i ent s ’ , ’

c a l l b a c k h e a l t h c o n d i t i o n s r e s t r i c t i o n s ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ preparat ion procedure ’ , ’ Procedure ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ c a l o r i e s ’ , ’ Ca lo r i e s ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ carbohydrate ’ , ’ Carbohydrates ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ prote in ’ , ’ Protein ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ fat ’ , ’ Fat ’ , ’ r equ i r ed | numeric ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// echo ’<pre > ’ . p r i n t r ( $th i s−>input−>post ( ) ,TRUE) . ’</pre > ’ ;// d i e ( ) ;// $th i s−>index ( ) ;// i f ( $th i s−>input−>post ( ) )

//{// Merge the submitted data with the cur rent data

// $data = $th i s−>input−>post ( ) ;// echo ’<pre > ’ . p r i n t r ( $data ) . ’</pre > ’ ;

// d i e ( ) ;//}

// $data = $th i s−>input−>post ( ) ;// $ i n g r ed i en t s = $th i s−>input−>post ( ’ i ng r ed i en t s ’ ) ;// echo ’<pre > ’ . p r i n t r ( $ i n g r ed i en t s ) . ’</pre > ’ ;// d i e ( ) ;

// echo ’<pre > ’ . p r i n t r ( $data ) . ’</pre > ’ ;// d i e ( ) ;

$ th i s−>load−>view ( ’ add rec ipe cmanager index ’/∗ , $data ∗/) ;}e l s e {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

/∗Create c on f i g f o r image l i b r a r y ∗/$th i s−>load−>l i b r a r y ( ’ image l ib ’ ) ;

186

Page 198: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$con f i g [ ’ image l ib ra ry ’ ] = ’ gd2 ’ ;

/∗ Create c on f i g f o r upload l i b r a r y ∗/$con f i g [ ’ upload path ’ ] = ’ . / uploads / ’ ;$ con f i g [ ’ a l lowed types ’ ] = ’ g i f | jpg | png ’ ;$ con f i g [ ’ max size ’ ] = ’ 0 ’ ;$ con f i g [ ’ max width ’ ] = ’ 0 ’ ;$ con f i g [ ’ max height ’ ] = ’ 0 ’ ;$ th i s−>load−>l i b r a r y ( ’ upload ’ , $ con f i g ) ;

i f ( ! $ th i s−>upload−>do upload ( ’ 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 = array ( ’ e r ror ’ => $th i s−>upload−>d i s p l a y e r r o r s ( ) ) ;

$ e r r o r = $th 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 ;$ th i s−>load−>view ( ’

add rec ipe cmanager index ’ , $data );

} e l s e {

$ f i l ename = ’ de fau l t ’ ;$ f i l eEx t en s i o n = ’png ’ ;

$data3 [ ’ raw name ’ ] = $f i l ename ;$data3 [ ’ f i l e e x t ’ ] = $ f i l eEx t en s i o n ;

$ f i l e=array (’ img name’=>$data3 [ ’ raw name

’ ] ,’ thumb name’=>$data3 [ ’ raw name

’ ] . ’ thumb ’ ,’ ext ’=>$data3 [ ’ f i l e e x t ’ ] ,’ upload date ’=>time ( )

) ;

$ th i s−>home cmanager model−>proc e s s add r e c i p e ($ f i l e ) ;

}} e l s e {

$data3=$th i s−>upload−>data ( ) ;$pa th in f o = path in fo ( $ FILES [” u s e r f i l e ” ] [ ”

name ” ] ) ;$ f i l ename = $path in f o [ ’ f i l ename ’ ] ;$ f i l eEx t en s i o n = $path in f o [ ’ extens ion ’ ] ;

// $data3=$th i s−>upload−>data ( ) ;// $th i s−>thumb( $data3 ) ;

$data3 [ ’ raw name ’ ] = $f i l ename ;$data3 [ ’ f i l e e x t ’ ] = $ f i l eEx t en s i o n ;

$ f i l e=array (’ img name’=>$data3 [ ’ raw name

’ ] ,’ thumb name’=>$data3 [ ’ raw name

’ ] . ’ thumb ’ ,’ ext ’=>$data3 [ ’ f i l e e x t ’ ] ,’ upload date ’=>time ( )

) ;

$ th i s−>home cmanager model−>proc e s s add r e c i p e ($ f i l e ) ;

$data3 = array ( ’ upload data ’ => $th i s−>upload−>data ( ) ) ;

}

// $message = ”Creat ing o f Recipe Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . /

home cmanager/show c r ea t ed r e c i p e s ”) ;

//</ s c r i p t > ’ ;//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

Creat ing o f Recipe Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home cmanager/ show crea t ed r e c ipe s

’ , ’ r e f r e sh ’ ) ;}

}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

/∗ f unc t i on thumb( $data3 ) {$con f i g [ ’ image l ib ra ry ’ ] = ’ gd2 ’ ;$ con f i g [ ’ source image ’ ] =$data3 [ ’ f u l l p a th ’ ] ;$ con f i g [ ’ create thumb ’ ] = TRUE;$con f i g [ ’ ma inta in ra t i o ’ ] = TRUE;

187

Page 199: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$con f i g [ ’ width ’ ] = 275 ;$ con f i g [ ’ height ’ ] = 250 ;$th i s−>load−>l i b r a r y ( ’ image l ib ’ , $ con f i g ) ;$ th i s−>image l ib−>r e s i z e ( ) ;

}∗/

func t i on h e a l t h c o n d i t i o n s r e s t r i c t i o n s ( $ i n g r ed i en t s ) {$hea l th cond i t i on = $ POST [ ’ hea l th cond i t i on ’ ] ;f o r ( $ i = 0 ; $ i < count ( $ i n g r ed i en t s ) ; $ i++) {

i f ( ! i s s e t ( $ i n g r ed i en t s [ $ i ] ) ) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’The

Ing r ed i en t f i e l d i s r equ i r ed . ’ ) ;r e turn f a l s e ;

}

i f ( ! i s s e t ($ POST [ ’ i ng r ed i en t quant i t y ’ ] [ $ i ] ) ) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’The

Quantity f i e l d i s r equ i r ed . ’ ) ;r e turn f a l s e ;

}

$food group = $ POST [ ’ food group ’ ] [ $ i ] ;$counts = 0 ;

f o r ( $ j = 0 ; $ j < count ( $ i n g r ed i en t s ) ; $ j++) {i f ($ POST [ ’ food group ’ ] [ $ i ] == $food group )

$counts += $ POST [ ’ i ng r ed i en t quant i t y ’ ] [ $ j ] ;}

i f ( $h ea l th cond i t i on == ’ Diabetes ’ ) {i f ( ( $ food group === ”Vegetable ” | | $food group === ”Frui t ”) &&

$counts > 4) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 4 s e r v i ng s o f ’ .$ food group . ’ da i l y . ’ ) ;

r e turn f a l s e ;} e l s e i f ( $ food group === ”Milk” && $counts > 3) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 3 s e r v i ng s o f Milk

da i l y . ’ ) ;r e turn f a l s e ;

} e l s e i f ( $ food group === ”Rice ” && $counts > 9) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 9 s e r v i ng s o f Riceda i l y . ’ ) ;

r e turn f a l s e ;} e l s e i f ( $ food group === ”Meat” && $counts > 6) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 6 s e r v i ng s o f Meat

da i l y . ’ ) ;r e turn f a l s e ;

} e l s e i f ( $ food group === ”Meat” && $counts > 5) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 5 s e r v i ng s o f Fatda i l y . ’ ) ;

r e turn f a l s e ;}

} e l s e i f ( $hea l th cond i t i on == ’ Hypertension ’ | | $hea l th cond i t i on ==’Kidney Stones ’ ) {

i f ( ( $ food group === ”Vegetable ” | | $food group === ”Frui t ”) &&$counts > 5) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 5 s e r v i ng s o f ’ .

$ food group . ’ da i l y . ’ ) ;r e turn f a l s e ;

} e l s e i f ( $ food group === ”Milk” && $counts > 5) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 5 s e r v i ng s o f Milkda i l y . ’ ) ;

r e turn f a l s e ;} e l s e i f ( $ food group === ”Rice ” && $counts > 8) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 8 s e r v i ng s o f Rice

da i l y . ’ ) ;r e turn f a l s e ;

} e l s e i f ( $ food group === ”Meat” && $counts > 2) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 2 s e r v i ng s o f Meatda i l y . ’ ) ;

r e turn f a l s e ;} e l s e i f ( $ food group === ”Meat” && $counts > 3) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 3 s e r v i ng s o f Fat

da i l y . ’ ) ;r e turn f a l s e ;

}}

re turn true ;}

}

//AUTOCOMPLETE ADD INGREDIENTSfunc t i on sugge s t i on s ( ) {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;$term = $th i s−>input−>post ( ’ term ’ ,TRUE) ;

i f ( s t r l e n ( $term ) < 1) break ;

188

Page 200: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$rows = $th i s−>home cmanager model−>GetAutocomplete ( array ( ’ keyword ’ => $term ) );

$ j s on a r r ay = array ( ) ;f o r each ( $rows as $row ){// array push ( $ j son ar ray , $row−>food name , $row−>measure ) ;$ j s on a r r ay [ ] [ ’ food name ’ ] = $row−>food name ;$ j s on a r r ay [ ] [ ’ measure ’ ] = $row−>we i gh t ed i b l e po r t i on ;$ j s on a r r ay [ ] [ ’ energy ’ ] = $row−>energy ;$ j s on a r r ay [ ] [ ’ carbohydrate ’ ] = $row−>carbohydrate ;$ j s on a r r ay [ ] [ ’ prote in ’ ] = $row−>pro t e in ;$ j s on a r r ay [ ] [ ’ fat ’ ] = $row−>f a t ;$ j s on a r r ay [ ] [ ’ food group ’ ] = $row−>food group ;}echo j son encode ( $ j s on a r r ay ) ;

}

f unc t i on g e t f a ( ) {$th i s−>load−>model ( ’ home cmanager model ’ ) ;$ i ng r ed i en t = $th i s−>input−>post ( ’ i ng r ed i en t ’ ) ;i f ( s t r l e n ( $ i ng r ed i en t ) < 1) break ;

$rows = $th i s−>home cmanager model−>GetAutocomplete ( array ( ’ keyword ’ =>$ ing r ed i en t ) ) ;

$response = ”” ;f o r each ( $rows as $row )$response = $row−>energy . ” , ” . $row−>carbohydrate . ” , ” . $row−>pro t e in . ” , ” . $row−>

f a t ;

echo $response ;}

//PLAN DAILY MEALSfunc t i on recommend dai ly meals ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ recommend dai ly meals index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW SELECTED RECIPE UNDER RECOMMEND MEALSfunc t i on view created recommended rec ipe ( $recommended rec ipe id ) {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;$data [ ’ query ’ ] = $th i s−>home cmanager model−>g e t r e c i p e c on t e n t s (

$recommended rec ipe id ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ view recipe recommended index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW DAILY MEALS BY DATEpub l i c func t i on s e l e c t b y da t e ( ) {

$reco rd date = $th i s−>input−>post ( ’ r ecord date ’ ) ;i f ( $ r e co rd date != ””) {

$ r e s u l t = $th i s−>home cmanager model−>show data by date ( $ r eco rd 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 ;} e l s e {

$data [ ’ r e s u l t d i s p l a y ’ ] = ”No record found ! ” ;}} e l s e {

$data [ ’ date e r ro r message ’ ] = ”Date f i e l d i s r equ i r ed ” ;}// $data [ ’ show table ’ ] = $th i s−>v i ew tab l e ( ) ;$ th i s−>load−>view ( ’ recommend dai ly meals index ’ , $data ) ;//var dump ( $ r e s u l t ) ;

}

//SEARCH MEALfunc t i on search meal ( ) {

// $th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s// $th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ r ecord date ’ , ’Date ’ , ’ r equ i red ’ ) ;

189

Page 201: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

// i f ( $th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;// $th i s−>load−>view ( ’ p l an da i l y mea l s i ndex ’ ) ;

//}// e l s e {

// i f ( $th i s−>input−>post ( ’ submit ’ ) ) {// $data [ ’ r ecord date ’ ] = $th i s−>input−>post ( ’ r ecord date ’ ) ;//}$th i s−>load−>model ( ’ home cmanager model ’ ) ;$data [ ’ query meal ’ ] = $th i s−>home cmanager model−>ge t s ea r ch mea l ( ) ;$ th i s−>load−>view ( ’ search meal cmanager index ’ , $data ) ;

//}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//ADD MEALfunc t i on add meal ( $recommended rec ipe id ) {

$data [ ’ recommended recipe id ’ ] = $recommended rec ipe id ;

$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home cmanager model−>process addmeal ($recommended rec ipe id ) ;

// $message = ”Adding o f Meal Su c c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / search meal ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

Adding o f Meal Su c c e s s f u l . ’ ) ;r e d i r e c t ( ’ home cmanager/ search meal ’ , ’ r e f r e sh

’ ) ;}

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ middle name ’ ] = $ s e s s i on da t a [ ’ middle name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ add meal cmanager index ’ , $data ) ;}

//DELETE MEALfunc t i on de l e t e mea l ( $recommended dai ly meal id ) {

$th i s−>home cmanager model−>de l mea l ( $recommended dai ly meal id ) ;// $message = ”Meal was s u c c e s f u l l y de l e t ed ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / s e l e c t b y da t e ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’Meal was s u c c e s s f u l l y

de l e t ed . ’ ) ;r e d i r e c t ( ’ home cmanager/ s e l e c t by da t e ’ , ’

r e f r e sh ’ ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW SELECTED RECIPE FOR MEALfunc t i on v i ew c r ea t ed r e c i p e mea l ( $recommended rec ipe id ) {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;$data [ ’ query ’ ] = $th i s−>home cmanager model−>g e t r e c i p e c on t e n t s (

$recommended rec ipe id ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

190

Page 202: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v iew rec ipe add meal cmanager index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//EDIT FEL CONTROLLERfunc t i on e d i t f e l ( $ f o o d e x c h an g e l i s t i d ) {$item = $th i s−>home cmanager model−>g e t f e l e d i t ( $ f o o d e x c h an g e l i s t i d ) ;$ th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ l i s t g r oup ’ , ’ L i s t Group ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ food group ’ , ’ Food Group ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ food group category ’ , ’ Food Group Category ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ food name ’ , ’ Food Name’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ measure ’ , ’Measure ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ carbohydrate ’ , ’ Carbohydrate ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ prote in ’ , ’ Protein ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ fat ’ , ’ Fat ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ energy ’ , ’ Energy ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ we ight as purchased ’ , ’Weight as Purchased ’

, ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ we i gh t ed ib l e po r t i on ’ , ’Weight Edible

Portion ’ , ’ r equ i r ed | numeric ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

// ’ l i s t g r oup ’ => $th i s−>input−>post ( ’ l i s t g r oup ’ ) ,// ’ food group ’ => $th i s−>input−>post ( ’ food group ’ ) ,// ’ food group category ’ => $th i s−>input−>post ( ’

food group category ’ ) ,’ food name ’ => $th i s−>input−>post ( ’ food name ’ ) ,’ measure ’ => $th i s−>input−>post ( ’ measure ’ ) ,’ carbohydrate ’ => $th i s−>input−>post ( ’ carbohydrate ’ ) ,’ prote in ’ => $th i s−>input−>post ( ’ prote in ’ ) ,’ fat ’ => $th i s−>input−>post ( ’ fat ’ ) ,’ energy ’ => $th i s−>input−>post ( ’ energy ’ ) ,’ we ight as purchased ’ => $th i s−>input−>post ( ’

we ight as purchased ’ ) ,’ we i gh t ed ib l e po r t i on ’ => $th i s−>input−>post ( ’

we i gh t ed ib l e po r t i on ’ )) ;

i f ( i s s e t ($ POST [ ’ l i s t g r oupo th e r ’ ] , $ POST [ ’ food groupother ’ ] , $ POST[ ’ f ood group categoryother ’ ] ) ) {

$data [ ’ l i s t g r oup ’ ] = $th i s−>input−>post ( ’ l i s t g r oupo th e r ’ ) ;$data [ ’ food group ’ ] = $th i s−>input−>post ( ’ food groupother ’ ) ;$data [ ’ food group category ’ ] = $th i s−>input−>post ( ’

f ood group categoryother ’ ) ;} e l s e {

$data [ ’ l i s t g r oup ’ ] = $th i s−>input−>post ( ’ l i s t g r oup ’ ) ;$data [ ’ food group ’ ] = $th i s−>input−>post ( ’ food group ’ ) ;$data [ ’ food group category ’ ] = $th i s−>input−>post ( ’

food group category ’ ) ;}

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home cmanager model−>upda t e f e l ($ f o od ex chang e l i s t i d , $data ) ;

// $message = ”Update Food Exchange L i s t ItemSuc c e s s f u l ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home cmanager ”);

//</ s c r i p t > ’ ;//}

$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’Update Food Exchange L i s t Item Suc c e s s f u l. ’ ) ;

r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;}

}}$data [ ’ item ’ ] = $item ;$data [ ’ l i s t g r oup ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ l i s t g r oup ’ , $item [ ’

l i s t g r oup ’ ] ) ;$data [ ’ food group ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ food group ’ , $item [ ’

food group ’ ] ) ;$data [ ’ f ood group category ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’

food group category ’ , $item [ ’ food group category ’ ] ) ;$data [ ’ food name ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ food name ’ , $item [ ’

food name ’ ] ) ;$data [ ’ measure ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ measure ’ , $item [ ’

measure ’ ] ) ;

191

Page 203: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ carbohydrate ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ carbohydrate ’ ,$item [ ’ carbohydrate ’ ] ) ;

$data [ ’ prote in ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ prote in ’ , $item [ ’prote in ’ ] ) ;

$data [ ’ fat ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ fat ’ , $item [ ’ fat ’ ] ) ;$data [ ’ energy ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ energy ’ , $item [ ’ energy

’ ] ) ;$data [ ’ we ight as purchased ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’

we ight as purchased ’ , $item [ ’ we ight as purchased ’ ] ) ;$data [ ’ we i gh t ed ib l e po r t i on ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’

we i gh t ed ib l e po r t i on ’ , $item [ ’ we i gh t ed ib l e po r t i on ’ ] ) ;$data [ ’ lg ’ ] = $th i s−>home cmanager model−>g e t l i s t g r o u p ( ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ e d i t f e l i n d e x ’ , $data ) ;

}

//EDIT HT CONTROLLERfunc t i on ed i t h t ( $ h e a l t h t i p i d ) {$item = $th 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 ) ;$ th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ h ea l th t i p ’ , ’ Health Tip ’ , ’ r equ i red ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

’ h ea l th t i p ’ => $th i s−>input−>post ( ’ h ea l th t i p ’ )) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ home cmanager model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home cmanager model−>update ht ( $h e a l t h t i p i d ,$data ) ;

// $message = ”Edit Health Tip Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . / home cmanager ”)

;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

Edit Health Tip Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home cmanager ’ , ’ r e f r e sh ’ ) ;

}}

}$data [ ’ item ’ ] = $item ;$data [ ’ h ea l th t i p ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ h ea l th t i p ’ , $item [ ’

h ea l th t i p ’ ] ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ ed i t h t i ndex ’ , $data ) ;

}}

?>

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;s e s s i o n s t a r t ( ) ; //we need to c a l l PHP’ s s e s s i o n ob j e c t to ac c e s s i t through CI

c l a s s Home User extends CI Cont ro l l e r {

f unc t i on c on s t r u c t ( ) {parent : : c o n s t r u c t ( ) ;$ th i s−>load−>he lpe r ( array ( ’ form ’ , ’ ur l ’ ) ) ;$ th i s−>load−>model ( ’ home user model ’ ) ;

}

f unc t i on index ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ u s e r id ’ ] = $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;

192

Page 204: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ home user index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

f unc t i on logout ( ) {$th i s−>s e s s i on−>unse t use rdata ( ’ l ogged in ’ ) ;s e s s i o n d e s t r o y ( ) ;r e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

pub l i c func t i on check use r ( ) {$usr=$th i s−>input−>post ( ’ name ’ ) ;$ r e s u l t=$th i s−>home user model−>c h e c k u s e r e x i s t ( $usr ) ;i f ( $ r e s u l t ) {

echo ” f a l s e ” ;}e l s e {

echo ” true ” ;}

}

pub l i c func t i on check emai l ( ) {$eml=$th i s−>input−>post ( ’ email ’ ) ;$ r e s u l t=$th i s−>home user model−>ch e c k ema i l e x i s t ( $eml ) ;i f ( $ r e s u l t ) {

echo ” f a l s e ” ;}e l s e {

echo ” true ” ;}

}

//EDIT PASSWORD CONTROLLERfunc t i on ed i t pa s sword use r ( ) {

$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ old password ’ , ’Old Password ’ , ’ tr im |

r equ i r ed | min length [ 8 ] | ca l lback check o ld pas sword ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ tr im | r equ i r ed |

min length [ 8 ] ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ conf irm password ’ , ’ Confirm Password ’ , ’

tr im | r equ i r ed |matches [ password ] ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

’ password ’ => MD5( $th i s−>input−>post ( ’ password ’ ) ) ,’ conf irm password ’ => MD5( $th i s−>input−>post ( ’ conf irm password

’ ) )) ;

$username = $th i s−>input−>post ( ’ username ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ home user model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home user model−>update password ( $username ,$data ) ;

// $message = ”Password Change Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . /

home user ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Password Change

Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home user ’ , ’ r e f r e sh ’ ) ;}

}}

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ ed i t pa s sword use r index ’ , $data ) ;}

pub l i c func t i on check o ld password ( ) {$opwd=MD5( $th i s−>input−>post ( ’ old password ’ ) ) ;$ r e s u l t=$th i s−>home user model−>che ck o ld pa s swo rd ex i s t ($opwd) ;i f ( $ r e s u l t ) {

re turn true ;}

193

Page 205: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

e l s e {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’ I n c o r r e c t Old

Password . ’ ) ;r e turn f a l s e ;

}}

//EDIT PROFILE CONTROLLERfunc t i on e d i t p r o f i l e u s e r ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ username ’ , ’Username ’ , ’ tr im | r equ i r ed |

min length [ 4 ] | xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ f i r s t name ’ , ’ F i r s t Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ middle name ’ , ’ Middle Name’ , ’ x s s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ last name ’ , ’ Last Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ b i r thdate ’ , ’ Birthdate ’ , ’ r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ genderRadio ’ , ’Gender ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ userTypeRadio ’ , ’ User Type ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ emai l address ’ , ’ Email Address ’ , ’ r equ i r ed |

va l id ema i l ’ ) ;

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

’ u s e r id ’ => $th i s−>input−>post ( ’ u s e r id ’ ) ,’ username ’ => $th i s−>input−>post ( ’ username ’ ) ,

’ f i r s t name ’ => $th i s−>input−>post ( ’ f i r s t name ’ ) ,’ middle name ’ => $th i s−>input−>post ( ’ middle name ’ ) ,’ last name ’ => $th i s−>input−>post ( ’ last name ’ ) ,’ gender ’ => $th i s−>input−>post ( ’ genderRadio ’ ) ,’ user type ’ => $th i s−>input−>post ( ’ userTypeRadio ’ ) ,’ emai l address ’ => $th i s−>input−>post ( ’ emai l address ’ ) ,’ birthday ’ => $th i s−>input−>post ( ’ b i r thdate ’ )

) ;

$username = $th i s−>input−>post ( ’ username ’ ) ;$u s e r i d = $th i s−>input−>post ( ’ user id ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>s e s s i on−>s e t u s e rda t a ( ’ l ogged in ’ , $data ) ;$th i s−>load−>model ( ’ home user model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home user model−>upda t e p r o f i l e ( $username ,$data ) ;

// $message = ” P r o f i l e Update Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . /

home user ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ P r o f i l e Update

Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home user ’ , ’ r e f r e sh ’ ) ;}

}}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ middle name ’ ] = $ s e s s i on da t a [ ’ middle name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ e d i t p r o f i l e u s e r i n d e x ’ , $data ) ;}

//SEARCH FOOD EXCHANGE LISTfunc t i on s e a r c h f e l ( ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ que ry f e l ’ ] = $th i s−>home user model−>g e t s e a r c h f e l ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

$ th i s−>load−>view ( ’ s e a r c h f e l u s e r i n d e x ’ , $data ) ;}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n page

194

Page 206: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

r e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;}

}

//HEALTH TIPS NEWS FEEDfunc t i on u s e r h t f e e d ( ) {

$th i s−>load−>model ( ’ home user model ’ ) ;/∗ $count = $th i s−>home user model−>count ht ( ) ;

$ th i s−>load−>l i b r a r y ( ’ paginat ion ’ ) ;$ con f i g [ ’ t o ta l rows ’ ] = $count ;

$ con f i g [ ’ per page ’ ] = 2 ;$th i s−>paginat ion−> i n i t i a l i z e ( $ con f i g ) ;$data [ ’ paginat ion ’ ] = $th i s−>paginat ion−>c r e a t e l i n k s ( ) ;

$data [ ’ h t f eed ’ ] = $th i s−>home user model−>g e t s e a r c h h t r e t ( array (’ l im i t ’ => $con f i g [ ’ per page ’ ] ,’ o f f s e t ’ => $th i s−>paginat ion−>o f f s e t ) ) ;∗/

$data [ ’ h t f eed ’ ] = $th i s−>home user model−>g e t s e a r ch h t ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ u s e r h t f e ed i ndex ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//ACHIEVEMENTS NEWS FEED//HEALTH TIPS NEWS FEEDfunc t i on use r ach i evement s f e ed ( ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ achievement feed ’ ] = $th i s−>home user model−>ge t s ea r ch ach i evement s ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ use r ach i evement f e ed index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//FITNESS PROFILEfunc t i on s h ow f i t n e s s p r o f i l e ( ) {

$data [ ’ query ’ ]= $th i s−>home user model−>proc e s s v i ew fp ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v i ew f i t n e s s p r o f i l e i n d e x ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

f unc t i on weightmonitor getdata ( ) {$we ightchart data = $th i s−>home user model−>ge t we ightcha r t da ta ( ) ;

$category = array ( ) ;$category [ ’ name ’ ] = ’ Category ’ ;

$ s e r i e s 1 = array ( ) ;$ s e r i e s 1 [ ’ name ’ ] = ’ Current Weight ’ ;

$ s e r i e s 2 = array ( ) ;$ s e r i e s 2 [ ’ name ’ ] = ’Goal Weight ’ ;

f o r each ( $we ightchart data as $row ) {$category [ ’ data ’ ] [ ] = $row−>r e co rd date ;

$ s e r i e s 1 [ ’ data ’ ] [ ] = $row−>cur r ent we ight ;$ s e r i e s 2 [ ’ data ’ ] [ ] = $row−>goa l we ight ;

}

$ r e s u l t = array ( ) ;

195

Page 207: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

array push ( $ r e su l t , $category ) ;array push ( $ r e su l t , $ s e r i e s 1 ) ;array push ( $ r e su l t , $ s e r i e s 2 ) ;

echo j son encode ( $ r e su l t , JSON NUMERIC CHECK) ;}

pub l i c func t i on c h e c k f i t n e s s p r o f i l e ( ) {$ r e c da t e=$th i s−>input−>post ( ’ r ecord date ’ ) ;$ r e s u l t=$th i s−>home user model−>c h e c k f p e x i s t ( $ r e c da t e ) ;i f ( $ r e s u l t ) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You a l ready entereddata f o r the s e l e c t e d date . ’ ) ;

r e turn f a l s e ;}e l s e {

re turn true ;

}}

f unc t i on a d d f i t n e s s p r o f i l e ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ a d d f i t n e s s p r o f i l e i n d e x ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

f unc t i on a d d f i t n e s s p r o f i l e s a v e ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ goa l we ight ’ , ’ Goal Weight ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ current we ight ’ , ’ Current Weight ’ , ’

r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ height ’ , ’ Height ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ r ecord date ’ , ’ Record Date ’ , ’ r equ i r ed |

c a l l b a c k c h e c k f i t n e s s p r o f i l e ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ h ea l th cond i t i on ’ , ’ Health Condition ’ , ’

requ i red ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;$ th i s−>load−>view ( ’ a d d f i t n e s s p r o f i l e i n d e x ’ ) ;

}e l s e {

$th i s−>load−>model ( ’ home user model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home user model−>proce s s add fp ( ) ;// $message = ”Adding o f In format ion Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home user / s h ow f i t n e s s p r o f i l e”) ;

//</ s c r i p t > ’ ;//}

$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ In format ions u c c e s s f u l l y added . ’ ) ;

r e d i r e c t ( ’ home user / s h ow f i t n e s s p r o f i l e ’ , ’ r e f r e sh ’ ) ;}

}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//DELETE FITNESS PROFILE CONTROLLERfunc t i on 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 ) {

$th i s−>home user model−>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 ) ;// $message = ” F i tne s s P r o f i l e was s u c c e s f u l l y de l e t ed ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / s h ow f i t n e s s p r o f i l e ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ F i tne s s P r o f i l e was

s u c c e s s f u l l y de l e t ed . ’ ) ;r e d i r e c t ( ’ home user / s h ow f i t n e s s p r o f i l e ’ , ’

r e f r e sh ’ ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;

196

Page 208: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//SHARE ACHIEVEMENT CONTROLLERSfunc t i on share achievement ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}$th i s−>load−>view ( ’ share ach ievement index ’ ) ;

}

f unc t i on share ach ievement save ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ achievement ’ , ’ Achievement ’ , ’ r equ i red ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;$ th i s−>load−>view ( ’ share ach ievement index ’ ) ;

}e l s e {

$th i s−>load−>model ( ’ home user model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home user model−>process ach ievement ( ) ;// $message = ”Sharing o f Achievement Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / home user ”) ;//</ s c r i p t > ’ ;//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Sharing o f

Achievement Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home user ’ , ’ r e f r e sh ’ ) ;

}}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW CREATED RECIPESfunc t i on show c r ea t ed r e c i p e s ( ) {

$data [ ’ query ’ ]= $th i s−>home user model−>p r o c e s s v i ew c r e a t e d r e c i p e s ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v i ew c r e a t ed r e c i p e s i nd ex ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//EDIT CREATED RECIPESfunc t i on e d i t c r e a t e d r e c i p e ( $own rec ipe id ) {$item = $th i s−>home user model−>g e t c r e a t e d r e c i p e ( $own rec ipe id ) ;$ th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s// $th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ own rec ipe id ’ , ’Username ’ , ’ tr im |

r equ i r ed | min length [ 4 ] | xs s c l ean ’ ) ;// $th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ u s e r id ’ , ’ F i r s t Name’ , ’ tr im | r equ i r ed |

xs s c l ean ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ h ea l th cond i t i on ’ , ’ Health Condition ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ meal type ’ , ’Meal Type ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ recipe name ’ , ’ Recipe Name’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ s e rv ing sugg ’ , ’ Serv ing Size ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ i ng r ed i en t s ’ , ’ Ing red i ent s ’ , ’

c a l l b a c k h e a l t h c o n d i t i o n s r e s t r i c t i o n s ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ preparat ion procedure ’ , ’ Procedure ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ c a l o r i e s ’ , ’ Ca lo r i e s ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ carbohydrate ’ , ’ Carbohydrates ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ prote in ’ , ’ Protein ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ fat ’ , ’ Fat ’ , ’ r equ i r ed | numeric ’ ) ;

197

Page 209: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

i f ( i s s e t ($ POST) && ! empty ($ POST) ) {$data = array (

// ’ own rec ipe id ’ => $th i s−>input−>post ( ’ own rec ipe id ’ ) ,// ’ u s e r id ’ => $th i s−>input−>post ( ’ u s e r id ’ ) ,// ’ hea l th cond i t i on ’ => $th i s−>input−>post ( ’ h ea l th cond i t i on ’ )

,’ h ea l th cond i t i on ’ => implode (” ,” , $th i s−>input−>post ( ’

h ea l th cond i t i on ’ ) ) ,’ meal type ’ => $th i s−>input−>post ( ’ meal type ’ ) ,’ recipe name ’ => $th i s−>input−>post ( ’ recipe name ’ ) ,’ s e rv ing sugg ’ => $th i s−>input−>post ( ’ s e rv ing sugg ’ ) ,’ p reparat ion procedure ’ => $th i s−>input−>post ( ’

preparat ion procedure ’ ) ,’ c a l o r i e s ’ => $th i s−>input−>post ( ’ c a l o r i e s ’ ) ,’ carbohydrate ’ => $th i s−>input−>post ( ’ carbohydrate ’ ) ,’ prote in ’ => $th i s−>input−>post ( ’ prote in ’ ) ,’ fat ’ => $th i s−>input−>post ( ’ fat ’ )

) ;

$data2 = array ( ) ;

$data2 [ ’ food name ’ ] = $th i s−>input−>post ( ’ i ng r ed i en t s ’ ) ;$data2 [ ’ food group ’ ] = $th i s−>input−>post ( ’ food group ’ ) ;$data2 [ ’ measure ’ ] = $th i s−>input−>post ( ’ ingred ient measure ’ ) ;$data2 [ ’ s e r v i n g s i z e ’ ] = $th i s−>input−>post ( ’ i ng r ed i en t quant i t y ’ ) ;$data2 [ ’ i n g r ed i en t i d ’ ] = $th i s−>input−>post ( ’ i n g r ed i en t i d ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ home user model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home user model−>update r e c ipe ( $own rec ipe id ,$data , $data2 ) ;

// $message = ”Edit Recipe Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . / home user ”) ;

//</ s c r i p t > ’ ;//}

$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Edit RecipeSuc c e s s f u l . ’ ) ;

r e d i r e c t ( ’ home user ’ , ’ r e f r e sh ’ ) ;}

}}$data [ ’ item ’ ] = $item ;// $data [ ’ own rec ipe id ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ own rec ipe id ’ ,

$item [ ’ own rec ipe id ’ ] ) ;// $data [ ’ u s e r id ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ u s e r id ’ , $item [ ’

u s e r id ’ ] ) ;// $data [ ’ h ea l th cond i t i on ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’

hea l th cond i t i on ’ , $item [ ’ hea l th cond i t i on ’ ] ) ;// $data [ ’ meal type ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ meal type ’ , $item [ ’

meal type ’ ] ) ;// $data [ ’ recipe name ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ recipe name ’ ,

$item [ ’ recipe name ’ ] ) ;// $data [ ’ s e rv ing sugg ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ s e rv ing sugg ’ ,

$item [ ’ s e rv ing sugg ’ ] ) ;

// $data [ ’ food name ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ i ng r ed i en t s ’ , $item[ ’ food name ’ ] ) ;

// $data [ ’ food group ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ food group ’ , $item[ ’ food group ’ ] ) ;

// $data [ ’ measure ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ ingred ient measure ’ ,$item [ ’ measure ’ ] ) ;

// $data [ ’ s e r v i n g s i z e ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’i ng r ed i en t quant i t y ’ , $item [ ’ s e r v i n g s i z e ’ ] ) ;

// $data [ ’ preparat ion procedure ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’preparat ion procedure ’ , $item [ ’ preparat ion procedure ’ ] ) ;

// $data [ ’ c a l o r i e s ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ c a l o r i e s ’ , $item [ ’c a l o r i e s ’ ] ) ;

// $data [ ’ carbohydrate ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ carbohydrate ’ ,$item [ ’ carbohydrate ’ ] ) ;

// $data [ ’ prote in ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ prote in ’ , $item [ ’prote in ’ ] ) ;

// $data [ ’ fat ’ ] = $th i s−>f o rm va l ida t i on−>s e t v a l u e ( ’ fat ’ , $item [ ’ fat ’ ] ) ;

// p r i n t r ( $item ) ;// d i e ( ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}$th i s−>load−>view ( ’ e d i t r e c i p e i nd e x ’ , $data ) ;

}

198

Page 210: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

//SHOW RECOMMENDED DAILY MEALSfunc t i on show recommended daily meals ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ show recommended dai ly meals index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//SELECT BY DATE RECOMMENDED MEALSpub l i c func t i on recommended se lect by date ( ) {

$reco rd date = $th i s−>input−>post ( ’ r ecord date ’ ) ;i f ( $ r e co rd date != ””) {

$ r e s u l t = $th i s−>home user model−>recommended show data by date ($ r eco rd 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 ;

} e l s e {$data [ ’ r e s u l t d i s p l a y ’ ] = ”No record found ! ” ;

}} e l s e {

$data [ ’ date e r ro r message ’ ] = ”Date f i e l d i s r equ i r ed ” ;}// $data [ ’ show table ’ ] = $th i s−>v i ew tab l e ( ) ;$ th i s−>load−>view ( ’ show recommended dai ly meals index ’ , $data ) ;//var dump ( $ r e s u l t ) ;

}

//VIEW SELECTED RECIPE UNDER RECOMMENDED MEALSfunc t i on view created recommended rec ipe ( $recommended rec ipe id ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query ’ ] = $th i s−>home user model−>get recommended rec ipe contents (

$recommended rec ipe id ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v iew dai ly recommended rec ipe index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW RECOMMENDED RECIPESfunc t i on show recommended recipes ( ) {

$data [ ’ query ’ ]= $th i s−>home user model−>process v iew recommended rec ipes ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v iew recommended rec ipes index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//SEARCH RECOMMENDED RECIPESfunc t i on s e a r c h r e c r e c ( ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query ’ ] = $th i s−>home user model−>g e t s e a r c h r e c r e c ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

$ th i s−>load−>view ( ’ v iew recommended rec ipes index ’ , $data ) ;}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

199

Page 211: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}

//VIEW SHARED RECIPESfunc t i on show shared r e c ipe s ( ) {

$data [ ’ query ’ ]= $th i s−>home user model−>p r o c e s s v i ew sha r ed r e c i p e s ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v i ew sha r ed r e c i p e s i ndex ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW SELECTED SHARED RECIPEfunc t i on v i ew sha r ed r e c i p e ( $ s h a r e d r e c i p e i d ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query ’ ] = $th i s−>home user model−>g e t s h a r e d r e c i p e c on t e n t s (

$ s h a r e d r e c i p e i d ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v i ew sha r ed r e c ip e index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//SEARCH SHARED RECIPESfunc t i on s ea r ch sha r ed r e c ( ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query ’ ] = $th i s−>home user model−>g e t s e a r ch sha r ed r e c ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

$ th i s−>load−>view ( ’ v i ew sha r ed r e c i p e s i ndex ’ , $data ) ;}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW SELECTED RECIPEfunc t i on v i ew c r e a t ed r e c i p e ( $own rec ipe id ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query ’ ] = $th i s−>home user model−>g e t r e c i p e c on t e n t s ( $own rec ipe id ) ;//var dump ( $data [ ’ query ’ ] ) ;// d i e ( ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v i ew rec ipe index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW SELECTED RECIPEfunc t i on view recommended recipe ( $recommended rec ipe id ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query ’ ] = $th i s−>home user model−>get recommended rec ipe contents (

$recommended rec ipe id ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;

200

Page 212: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ view recommended recipe index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//DELETE CREATED RECIPEfunc t i on d e l e t e c r e a t e d r e c i p e ( $own rec ipe id ) {

$th i s−>home user model−>d e l c r e a t e d r e c i p e ( $own rec ipe id ) ;// $message = ”Recipe was s u c c e s f u l l y de l e t ed ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / show c r ea t ed r e c i p e s ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Recipe was s u c c e s s f u l l y

de l e t ed . ’ ) ;r e d i r e c t ( ’ home user / show crea t ed r e c ipe s ’ , ’ r e f r e sh ’ ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//DELETE INGREDIENTSfunc t i on d e l e t e i n g r e d i e n t ( ) {

$th i s−>home user model−>d e l i n g r e d i e n t ( $th i s−>input−>post ( ’ i n g r ed i en t i d ’ ) ) ;}

//SHARE RECIPEfunc t i on s h a r e c r e a t e d r e c i p e ( $own rec ipe id ) {

// $own rec ipe id = $th i s−>input−>post ( ’ own rec ipe id ’ ) ;// $data [ ’ own rec ipe id ’ ] = $own rec ipe id ;// echo $own rec ipe id ;

$th i s−>load−>model ( ’ home user model ’ ) ;// i f ( $th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home user model−>p r o c e s s s h a r e r e c i p e ($own rec ipe id ) ;

// $message = ”Sharing o f Recipe Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / show c r ea t ed r e c i p e s ”) ;//</ s c r i p t > ’ ;

//}//}

$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’ Sharing o f RecipeSuc c e s s f u l . ’ ) ;

r e d i r e c t ( ’ home user / show crea t ed r e c ipe s ’ , ’ r e f r e sh ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ middle name ’ ] = $ s e s s i on da t a [ ’ middle name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//CREATE RECIPE CONTROLLERfunc t i on add rec ipe ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ add rec ipe index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

f unc t i on add r e c i p e s ave ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

201

Page 213: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ h ea l th cond i t i on ’ , ’ Health Condition ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ meal type ’ , ’Meal Type ’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ recipe name ’ , ’ Recipe Name’ , ’ requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ s e rv ing sugg ’ , ’ Serv ing Size ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ i ng r ed i en t s ’ , ’ Ing red i ent s ’ , ’

c a l l b a c k h e a l t h c o n d i t i o n s r e s t r i c t i o n s ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ preparat ion procedure ’ , ’ Procedure ’ , ’

requ i red ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ c a l o r i e s ’ , ’ Ca lo r i e s ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ carbohydrate ’ , ’ Carbohydrates ’ , ’ r equ i r ed |

numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ prote in ’ , ’ Protein ’ , ’ r equ i r ed | numeric ’ ) ;$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ fat ’ , ’ Fat ’ , ’ r equ i r ed | numeric ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// echo ’<pre > ’ . p r i n t r ( $th i s−>input−>post ( ) ,TRUE) . ’</pre > ’ ;// d i e ( ) ;// $th i s−>index ( ) ;// i f ( $th i s−>input−>post ( ) )

//{// Merge the submitted data with the cur rent data

// $data = $th i s−>input−>post ( ) ;// echo ’<pre > ’ . p r i n t r ( $data ) . ’</pre > ’ ;

// d i e ( ) ;//}

// $data = $th i s−>input−>post ( ) ;// $ i n g r ed i en t s = $th i s−>input−>post ( ’ i ng r ed i en t s ’ ) ;// echo ’<pre > ’ . p r i n t r ( $ i n g r ed i en t s ) . ’</pre > ’ ;// d i e ( ) ;

// echo ’<pre > ’ . p r i n t r ( $data ) . ’</pre > ’ ;// d i e ( ) ;

$ th i s−>load−>view ( ’ add rec ipe index ’/∗ , $data ∗/) ;}e l s e {

$th i s−>load−>model ( ’ home user model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

/∗Create c on f i g f o r image l i b r a r y ∗/$th i s−>load−>l i b r a r y ( ’ image l ib ’ ) ;$ con f i g [ ’ image l ib ra ry ’ ] = ’ gd2 ’ ;

/∗ Create c on f i g f o r upload l i b r a r y ∗/$con f i g [ ’ upload path ’ ] = ’ . / uploads / ’ ;$ con f i g [ ’ a l lowed types ’ ] = ’ g i f | jpg | png ’ ;$ con f i g [ ’ max size ’ ] = ’ 0 ’ ;$ con f i g [ ’ max width ’ ] = ’ 0 ’ ;$ con f i g [ ’ max height ’ ] = ’ 0 ’ ;$ th i s−>load−>l i b r a r y ( ’ upload ’ , $ con f i g ) ;

i f ( ! $ th i s−>upload−>do upload ( ’ 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 = array ( ’ e r ror ’ => $th i s−>upload−>d i s p l a y e r r o r s ( ) ) ;

$ e r r o r = $th 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 ;$ th i s−>load−>view ( ’ add rec ipe index ’ ,

$data ) ;} e l s e {

$ f i l ename = ’ de fau l t ’ ;$ f i l eEx t en s i o n = ’png ’ ;

$data3 [ ’ raw name ’ ] = $f i l ename ;$data3 [ ’ f i l e e x t ’ ] = $ f i l eEx t en s i o n ;

$ f i l e=array (’ img name’=>$data3 [ ’ raw name

’ ] ,’ thumb name’=>$data3 [ ’ raw name

’ ] . ’ thumb ’ ,’ ext ’=>$data3 [ ’ f i l e e x t ’ ] ,’ upload date ’=>time ( )

) ;

$ th i s−>home user model−>proc e s s add r e c i p e ($ f i l e ) ;

}} e l s e {

$data3=$th i s−>upload−>data ( ) ;$pa th in f o = path in fo ( $ FILES [” u s e r f i l e ” ] [ ”

name ” ] ) ;$ f i l ename = $path in f o [ ’ f i l ename ’ ] ;$ f i l eEx t en s i o n = $path in f o [ ’ extens ion ’ ] ;

// $data3=$th i s−>upload−>data ( ) ;// $th i s−>thumb( $data3 ) ;

$data3 [ ’ raw name ’ ] = $f i l ename ;$data3 [ ’ f i l e e x t ’ ] = $ f i l eEx t en s i o n ;

$ f i l e=array (’ img name’=>$data3 [ ’ raw name

’ ] ,

202

Page 214: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

’ thumb name’=>$data3 [ ’ raw name’ ] . ’ thumb ’ ,

’ ext ’=>$data3 [ ’ f i l e e x t ’ ] ,’ upload date ’=>time ( )

) ;

$ th i s−>home user model−>proc e s s add r e c i p e ($ f i l e ) ;

$data3 = array ( ’ upload data ’ => $th i s−>upload−>data ( ) ) ;

}

// $message = ”Creat ing o f Recipe Suc c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

// echo ’< s c r i p t>// l o c a t i on . r ep l a c e ( ” . . /

home user /show c r ea t ed r e c i p e s ”) ;

//</ s c r i p t > ’ ;//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

Creat ing o f Recipe Suc c e s s f u l . ’ ) ;r e d i r e c t ( ’ home user / show crea t ed r e c ipe s ’ , ’

r e f r e sh ’ ) ;}

}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

/∗ f unc t i on thumb( $data3 ) {$con f i g [ ’ image l ib ra ry ’ ] = ’ gd2 ’ ;$ con f i g [ ’ source image ’ ] =$data3 [ ’ f u l l p a th ’ ] ;$ con f i g [ ’ create thumb ’ ] = TRUE;$con f i g [ ’ ma inta in ra t i o ’ ] = TRUE;$con f i g [ ’ width ’ ] = 275 ;$ con f i g [ ’ height ’ ] = 250 ;$th i s−>load−>l i b r a r y ( ’ image l ib ’ , $ con f i g ) ;$ th i s−>image l ib−>r e s i z e ( ) ;

}∗/

func t i on h e a l t h c o n d i t i o n s r e s t r i c t i o n s ( $ i n g r ed i en t s ) {$hea l th cond i t i on = $ POST [ ’ hea l th cond i t i on ’ ] ;f o r ( $ i = 0 ; $ i < count ( $ i n g r ed i en t s ) ; $ i++) {

i f ( ! i s s e t ( $ i n g r ed i en t s [ $ i ] ) ) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’The

Ing r ed i en t f i e l d i s r equ i r ed . ’ ) ;r e turn f a l s e ;

}

i f ( ! i s s e t ($ POST [ ’ i ng r ed i en t quant i t y ’ ] [ $ i ] ) ) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’The

Quantity f i e l d i s r equ i r ed . ’ ) ;r e turn f a l s e ;

}

$food group = $ POST [ ’ food group ’ ] [ $ i ] ;$counts = 0 ;

f o r ( $ j = 0 ; $ j < count ( $ i n g r ed i en t s ) ; $ j++) {i f ($ POST [ ’ food group ’ ] [ $ i ] == $food group )

$counts += $ POST [ ’ i ng r ed i en t quant i t y ’ ] [ $ j ] ;}

i f ( $h ea l th cond i t i on == ’ Diabetes ’ ) {i f ( ( $ food group === ”Vegetable ” | | $food group === ”Frui t ”) &&

$counts > 4) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 4 s e r v i ng s o f ’ .$ food group . ’ da i l y . ’ ) ;

r e turn f a l s e ;} e l s e i f ( $ food group === ”Milk” && $counts > 3) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 3 s e r v i ng s o f Milk

da i l y . ’ ) ;r e turn f a l s e ;

} e l s e i f ( $ food group === ”Rice ” && $counts > 9) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 9 s e r v i ng s o f Riceda i l y . ’ ) ;

r e turn f a l s e ;} e l s e i f ( $ food group === ”Meat” && $counts > 6) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 6 s e r v i ng s o f Meat

da i l y . ’ ) ;r e turn f a l s e ;

} e l s e i f ( $ food group === ”Meat” && $counts > 5) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 5 s e r v i ng s o f Fatda i l y . ’ ) ;

r e turn f a l s e ;}

203

Page 215: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

} e l s e i f ( $hea l th cond i t i on == ’ Hypertension ’ | | $hea l th cond i t i on ==’Kidney Stones ’ ) {

i f ( ( $ food group === ”Vegetable ” | | $food group === ”Frui t ”) &&$counts > 5) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 5 s e r v i ng s o f ’ .

$ food group . ’ da i l y . ’ ) ;r e turn f a l s e ;

} e l s e i f ( $ food group === ”Milk” && $counts > 5) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 5 s e r v i ng s o f Milkda i l y . ’ ) ;

r e turn f a l s e ;} e l s e i f ( $ food group === ”Rice ” && $counts > 8) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 8 s e r v i ng s o f Rice

da i l y . ’ ) ;r e turn f a l s e ;

} e l s e i f ( $ food group === ”Meat” && $counts > 2) {$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’You

are only al lowed a maximum of 2 s e r v i ng s o f Meatda i l y . ’ ) ;

r e turn f a l s e ;} e l s e i f ( $ food group === ”Meat” && $counts > 3) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Youare only al lowed a maximum of 3 s e r v i ng s o f Fat

da i l y . ’ ) ;r e turn f a l s e ;

}}

re turn true ;}

}

//AUTOCOMPLETE ADD INGREDIENTS//USER SEARCH CONTROLLERSfunc t i on sugge s t i on s ( ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$term = $th i s−>input−>post ( ’ term ’ ,TRUE) ;

i f ( s t r l e n ( $term ) < 1) break ;

$rows = $th i s−>home user model−>GetAutocomplete ( array ( ’ keyword ’ => $term ) ) ;

$ j s on a r r ay = array ( ) ;f o r each ( $rows as $row ){// array push ( $ j son ar ray , $row−>food name , $row−>measure ) ;$ j s on a r r ay [ ] [ ’ food name ’ ] = $row−>food name ;$ j s on a r r ay [ ] [ ’ measure ’ ] = $row−>we i gh t ed i b l e po r t i on ;$ j s on a r r ay [ ] [ ’ energy ’ ] = $row−>energy ;$ j s on a r r ay [ ] [ ’ carbohydrate ’ ] = $row−>carbohydrate ;$ j s on a r r ay [ ] [ ’ prote in ’ ] = $row−>pro t e in ;$ j s on a r r ay [ ] [ ’ fat ’ ] = $row−>f a t ;$ j s on a r r ay [ ] [ ’ food group ’ ] = $row−>food group ;}echo j son encode ( $ j s on a r r ay ) ;

}

f unc t i on g e t f a ( ) {$th i s−>load−>model ( ’ home user model ’ ) ;$ i ng r ed i en t = $th i s−>input−>post ( ’ i ng r ed i en t ’ ) ;i f ( s t r l e n ( $ i ng r ed i en t ) < 1) break ;

$rows = $th i s−>home user model−>GetAutocomplete ( array ( ’ keyword ’ => $ ing r ed i en t) ) ;

$response = ”” ;f o r each ( $rows as $row )$response = $row−>energy . ” , ” . $row−>carbohydrate . ” , ” . $row−>pro t e in . ” , ” . $row−>

f a t ;

echo $response ;}

//PLAN DAILY MEALSfunc t i on p l an da i l y mea l s ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ p l an da i l y mea l s i ndex ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW SELECTED RECIPE UNDER PLAN MEALSfunc t i on v i ew c r e a t ed p l an r e c i p e ( $own rec ipe id ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query ’ ] = $th i s−>home user model−>g e t r e c i p e c on t e n t s ( $own rec ipe id ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

204

Page 216: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v i ew re c ip e p l an index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW DAILY MEALS BY DATEpub l i c func t i on s e l e c t b y da t e ( ) {

$reco rd date = $th i s−>input−>post ( ’ r ecord date ’ ) ;i f ( $ r e co rd date != ””) {

$ r e s u l t = $th i s−>home user model−>show data by date ( $ r eco rd 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 ;} e l s e {

$data [ ’ r e s u l t d i s p l a y ’ ] = ”No record found ! ” ;}} e l s e {

$data [ ’ date e r ro r message ’ ] = ”Date f i e l d i s r equ i r ed ” ;}// $data [ ’ show table ’ ] = $th i s−>v i ew tab l e ( ) ;$ th i s−>load−>view ( ’ p l an da i l y mea l s i ndex ’ , $data ) ;//var dump ( $ r e s u l t ) ;

}

//SEARCH MEALfunc t i on search meal ( ) {

// $th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s// $th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ r ecord date ’ , ’Date ’ , ’ r equ i red ’ ) ;

// i f ( $th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;// $th i s−>load−>view ( ’ p l an da i l y mea l s i ndex ’ ) ;

//}// e l s e {

// i f ( $th i s−>input−>post ( ’ submit ’ ) ) {// $data [ ’ r ecord date ’ ] = $th i s−>input−>post ( ’ r ecord date ’ ) ;//}$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query meal ’ ] = $th i s−>home user model−>ge t s ea r ch mea l ( ) ;$ th i s−>load−>view ( ’ search mea l index ’ , $data ) ;

//}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//ADD MEALfunc t i on add meal ( $own rec ipe id ) {

// $own rec ipe id = $th i s−>input−>post ( ’ own rec ipe id ’ ) ;$data [ ’ own rec ipe id ’ ] = $own rec ipe id ;// echo $own rec ipe id ;

$th i s−>load−>model ( ’ home user model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

$th i s−>home user model−>process addmeal ( $own rec ipe id) ;

// $message = ”Adding o f Meal Su c c e s s f u l ! ” ;// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / search meal ”) ;//</ s c r i p t > ’ ;

//}$th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’

Adding o f Meal Su 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 sh ’ ) ;

}

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ middle name ’ ] = $ s e s s i on da t a [ ’ middle name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;

205

Page 217: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

$th i s−>load−>view ( ’ add meal index ’ , $data ) ;}

//DELETE MEALfunc t i on de l e t e mea l ( $p l an da i l y mea l i d ) {

$th i s−>home user model−>de l mea l ( $p l an da i l y mea l i d ) ;// $message = ”Meal was s u c c e s f u l l y de l e t ed ! ” ;

// i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {// echo ’< s c r i p t>

// l o c a t i on . r ep l a c e ( ” . . / s e l e c t b y da t e ”) ;//</ s c r i p t > ’ ;$ th i s−>s e s s i on−>s e t f l a s h d a t a ( ’ success msg ’ , ’Meal was

s u c c e s s f u l l y de l e t ed . ’ ) ;r e d i r e c t ( ’ home user / s e l e c t by da t e ’ , ’ r e f r e sh ’ )

;//}i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//VIEW SELECTED RECIPE FOR MEALfunc t i on v i ew c r ea t ed r e c i p e mea l ( $own rec ipe id ) {

$th i s−>load−>model ( ’ home user model ’ ) ;$data [ ’ query ’ ] = $th i s−>home user model−>g e t r e c i p e c on t e n t s ( $own rec ipe id ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;$data [ ’ f i r s t name ’ ] = $ s e s s i on da t a [ ’ f i r s t name ’ ] ;$data [ ’ last name ’ ] = $ s e s s i on da t a [ ’ last name ’ ] ;$data [ ’ user type ’ ] = $ s e s s i on da t a [ ’ user type ’ ] ;$data [ ’ emai l address ’ ] = $ s e s s i on da t a [ ’ emai l address ’ ] ;$data [ ’ gender ’ ] = $ s e s s i on da t a [ ’ gender ’ ] ;$data [ ’ birthday ’ ] = $ s e s s i on da t a [ ’ birthday ’ ] ;$ th i s−>load−>view ( ’ v i ew rec ipe add mea l index ’ , $data ) ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}}

//FACEBOOKfunct i on share ach i evement fb ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$data [ ’ username ’ ] = $ s e s s i on da t a [ ’ username ’ ] ;

}e l s e {

// I f no s e s s i on , r e d i r e c t to l o g i n pager e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}$th i s−>load−>view ( ’ share ach i evement fb index ’ ) ;

}

f unc t i on pos t facebook ( ) {pa r s e s t r ( $ SERVER[ ’QUERY STRING’ ] , $ REQUEST ) ;$CI = & ge t i n s t an c e ( ) ;

$CI−>con f ig−>load (” facebook ” ,TRUE) ;$ con f i g = $CI−>con f ig−>item ( ’ facebook ’ ) ;$ th i s−>load−>l i b r a r y ( ’ Facebook ’ , $ con f i g ) ;

// Try to get the user ’ s id on Facebook$user Id = $th i s−>facebook−>getUser ( ) ;

// I f user i s not yet authent icated , the id w i l l be zeroi f ( $user Id == 0){

// Generate a l o g i n u r l$data [ ’ ur l ’ ] = $th i s−>facebook−>getLoginUrl ( array ( ’ scope ’=>’ email , pub l i s h ac t i on s

’ /∗ , ’ r e d i r e c t u r i ’ => ’ https :// a g i l a .upm. edu . ph/˜ pjd izon /FIM/home user /share ach ievement fb ’∗/ ) ) ;

$ur l = $data [ ’ ur l ’ ] ;echo ”<a h r e f =’ $url ’>Login</a>”;

// $th i s−>load−>view ( ’ share ach i evement fb index ’ , $data ) ;} e l s e {

// Get user ’ s data and pr in t i t// $user = $th i s−>facebook−>api ( ’/me ’ ) ;// p r i n t r ( $user ) ;

// $data [ ’ u s e r p r o f i l e ’ ] = $th i s−>facebook−>api ( ’/me ’ ) ;$ th i s−>facebook−>api ( ’/me/ feed / ’ , ’POST’ , array (

’ message ’ => $th i s−>input−>post ( ’ achievement ’ ) ,’ r e d i r e c t u r i ’ => ’ https :// a g i l a .upm. edu . ph/˜ pjd izon /

FIM/home user ’ ) ) ;

206

Page 218: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$message = ”Post ing o f Achievement to FacebookSuc c e s s f u l ! ” ;

i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {echo ’< 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 ep l a c e ( ” . . / home user ”) ;</s c r i p t > ’ ;

}

}}

/∗ f unc t i on po s t tw i t t e r ( ) {// I t r e a l l y i s best to auto−load t h i s l i b r a r y !$th i s−>load−>l i b r a r y ( ’ tweet ’ ) ;

// Enabling debug w i l l show you any e r r o r s in the c a l l s you ’ re making ,e . g :

$ th i s−>tweet−>enable debug (TRUE) ;

// I f you a l ready have a token saved f o r your user// ( In a db f o r example ) − See l i n e #37//// You can s e t these tokens be f o r e c a l l i n g l ogg ed in to try us ing the

e x i s t i n g tokens .// $tokens = array ( ’ oauth token ’ => ’ foo ’ , ’ oauth token sec r e t ’ => ’

bar ’ ) ;$tokens = array ( ’ oauth token ’ => ’787163882−5

XZQdNXKxKfxs7CMpnK8KOQfGG96p9obqSINTcab ’ , ’ oauth token sec r e t ’ =>’ lUqdGhuXJMbp2qLzhAsxFPxBOwPf7B5jek85ZugKHJ9qA ’ ) ;

$ th i s−>tweet−>s e t t ok en s ( $tokens ) ;

i f ( ! $ th i s−>tweet−>l o gg ed in ( ) ) {// This i s where the u r l w i l l go to a f t e r auth .// ( Cal lback u r l )$th i s−>tweet−>s e t c a l l b a c k ( s i t e u r l ( ’ home user /auth ’ ) ) ;// Send the user o f f f o r l o g i n !$th i s−>tweet−>l o g i n ( ) ;

}e l s e {

// You can get the tokens f o r the a c t i v e logged in user :// $tokens = $th i s−>tweet−>ge t tokens ( ) ;

//// These can be saved in a db a l ong s id e a user record// i f you a l ready have your own auth system .

}/∗$message = ”Post ing o f Achievement to Twitter Su c c e s s f u l ! ” ;

i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {echo ’< 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 ep l a c e ( ” . . / home user ”) ;</s c r i p t > ’ ;

}∗/// $tokens = $th i s−>tweet−>ge t tokens ( ) ;

// $user = $th i s−>tweet−>c a l l ( ’ get ’ , ’ account /v e r i f y c r ed en t i a aaaaaaaa l s ’ ) ;

//// Wil l throw an e r r o r with a s t a ck t r a c e .

/∗ $user = $th i s−>tweet−>c a l l ( ’ get ’ , ’ account / v e r i f y c r e d e n t i a l s ’ ) ;var dump ( $user ) ;

$ f r i e nd sh i p = $th i s−>tweet−>c a l l ( ’ get ’ , ’ f r i e n d s h i p s /show ’ , array( ’ source screen name ’ => $user−>screen name , ’ target screen name ’=> ’ pjud31 ’ ) ) ;

var dump ( $ f r i e nd sh i p ) ;

i f ( $ f r i endsh ip−>r e l a t i on sh i p−>target−>f o l l ow ing === FALSE ){

$th i s−>tweet−>c a l l ( ’ post ’ , ’ f r i e n d s h i p s / create ’ , array ( ’screen name ’ => $user−>screen name , ’ fo l l ow ’ => TRUE) ) ;

}

$th i s−>tweet−>c a l l ( ’ post ’ , ’ s t a t u s e s /update ’ , array ( ’ s tatus ’ => $th i s−>input−>post ( ’ achievement ’ ) ) ) ;

$opt ions = array (’ count ’ => 10 ,’ page ’ => 2 ,’ i n c l u d e e n t i t i e s ’ => 1

) ;

$ t ime l i n e = $th i s−>tweet−>c a l l ( ’ get ’ , ’ s t a t u s e s / home timel ine ’ ) ;

var dump ( $ t ime l i n e ) ;}∗//∗ f unc t i on auth ( ) {

$tokens = $th i s−>tweet−>ge t tokens ( ) ;

207

Page 219: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

// $user = $th i s−>tweet−>c a l l ( ’ get ’ , ’ account /v e r i f y c r ed en t i a aaaaaaaa l s ’ ) ;

//// Wil l throw an e r r o r with a s t a ck t r a c e .

$user = $th i s−>tweet−>c a l l ( ’ get ’ , ’ account / v e r i f y c r e d e n t i a l s ’ ) ;var dump ( $user ) ;

$ f r i e nd sh i p = $th i s−>tweet−>c a l l ( ’ get ’ , ’ f r i e n d s h i p s /show ’ , array( ’ source screen name ’ => $user−>screen name , ’ target screen name ’=> ’ pjud31 ’ ) ) ;

var dump ( $ f r i e nd sh i p ) ;

i f ( $ f r i endsh ip−>r e l a t i on sh i p−>target−>f o l l ow ing === FALSE ){

$th i s−>tweet−>c a l l ( ’ post ’ , ’ f r i e n d s h i p s / create ’ , array ( ’screen name ’ => $user−>screen name , ’ fo l l ow ’ => TRUE) ) ;

}

$th i s−>tweet−>c a l l ( ’ post ’ , ’ s t a t u s e s /update ’ , array ( ’ s tatus ’ => $th i s−>input−>post ( ’ achievement ’ ) ) ) ;

$opt ions = array (’ count ’ => 10 ,’ page ’ => 2 ,’ i n c l u d e e n t i t i e s ’ => 1

) ;

$ t ime l i n e = $th i s−>tweet−>c a l l ( ’ get ’ , ’ s t a t u s e s / home timel ine ’ ) ;

var dump ( $ t ime l i n e ) ;}∗/

}

?>

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;

c l a s s Login extends CI Cont ro l l e r {

f unc t i on c on s t r u c t ( ) {parent : : c o n s t r u c t ( ) ;$ th i s−>load−>model ( ’ log in model ’ ) ;

}

f unc t i on index ( ) {$th i s−>load−>he lpe r ( array ( ’ form ’ ) ) ;$ th i s−>load−>he lpe r ( ’ captcha ’ ) ;$va l s = array (

’ img path ’ => ’ . / captcha / ’ ,’ img url ’ => ’ https :// a g i l a .upm. edu . ph/˜ pjd izon /FIM/captcha / ’

) ;$cap = crea t e captcha ( $va l s ) ;$data = array (

’ captcha time ’ => $cap [ ’ time ’ ] ,’ i p addre s s ’ => $th i s−>input−>i p add r e s s ( ) ,’word ’ => $cap [ ’ word ’ ]

) ;$ th i s−>s e s s i on−>s e t u s e rda t a ( $data ) ;$data [ ’ cap img ’ ]= $cap [ ’ image ’ ] ;$ th i s−>load−>view ( ’ l og in index ’ , $data ) ;

}

f unc t i on save ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;// f i e l d name , e r r o r message , v a l i d a t i on r u l e s$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ username reg ’ , ’Username ’ , ’ tr im |

r equ i r ed | alpha numeric | min length [ 4 ] | x s s c l e an |c a l l b a c k ch e c k u s e r c i ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ password reg ’ , ’ Password ’ , ’ tr im |r equ i r ed | alpha numeric | min length [ 8 ] ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ conf i rm password reg ’ , ’ ConfirmPassword ’ , ’ tr im | r equ i r ed | alpha numeric |matches [ password reg ] ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ f i r s t name ’ , ’ F i r s t Name’ , ’ tr im |r equ i r ed | alpha numeric | xs s c l ean ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ middle name ’ , ’ Middle Name’ , ’a lpha numeric | xs s c l ean ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ last name ’ , ’ Last Name’ , ’ tr im |r equ i r ed | alpha numeric | xs s c l ean ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ b i r thdate ’ , ’ Birthdate ’ , ’r equ i r ed | xs s c l ean ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ genderRadio ’ , ’Gender ’ , ’ requ i red’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ userTypeRadio ’ , ’ User Type ’ , ’requ i red ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ emai l address ’ , ’ Email Address ’ ,’ r equ i r ed | va l i d ema i l | c a l l b a ck ch e ck ema i l c i ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ captcha ’ , ’ S e cur i ty Code ’ , ’ tr im |r equ i r ed | ca l lback check captcha ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {$th i s−>index ( ) ;

}e l s e {

$th i s−>load−>model ( ’ log in model ’ ) ;i f ( $ th i s−>input−>post ( ’ submit ’ ) ) {

208

Page 220: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$th i s−>log in model−>proce s s ( ) ;}

$message = ”Reg i s t r a t i on Suc c e s s f u l ! ” ;i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {

echo ’< 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 ep l a c e ( ” . . / l o g i n ”) ;

</s c r i p t > ’ ;}

}}

pub l i c func t i on check captcha ( ) {$exp i r a t i on = time ( ) −7200; // Two hour l im i t$cap=$th i s−>input−>post ( ’ captcha ’ ) ;i f ( $ th i s−>s e s s i on−>userdata ( ’ word ’ )== $cap

AND $th i s−>s e s s i on−>userdata ( ’ ip addre s s ’ )== $th i s−>input−>i p add r e s s ( )

AND $th i s−>s e s s i on−>userdata ( ’ captcha time ’ )> $exp i r a t i on ){

re turn true ;}e l s e {

$th i s−>f o rm va l ida t i on−>se t message ( ’ check captcha ’ , ’ S e cur i tynumber does not match . ’ ) ;

r e turn f a l s e ;}

}

pub l i c func t i on ch e c k u s e r c i ( ) {$usr=$th i s−>input−>post ( ’ username reg ’ ) ;$ r e s u l t=$th i s−>log in model−>c h e c k u s e r e x i s t ( $usr ) ;i f ( $ r e s u l t ) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’Usernamea l ready e x i s t s . ’ ) ;

r e turn f a l s e ;}e l s e {

re turn true ;}

}pub l i c func t i on check use r ( ) {

$usr=$th i s−>input−>post ( ’ name ’ ) ;$ r e s u l t=$th i s−>log in model−>c h e c k u s e r e x i s t ( $usr ) ;i f ( $ r e s u l t ) {

echo ” f a l s e ” ;}e l s e {

echo ” true ” ;}

}

pub l i c func t i on ch e ck ema i l c i ( ) {$eml=$th i s−>input−>post ( ’ emai l address ’ ) ;$ r e s u l t=$th i s−>log in model−>ch e c k ema i l e x i s t ( $eml ) ;i f ( $ r e s u l t ) {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’E−mail Addressa l ready r e g i s t e r e d . ’ ) ;

r e turn f a l s e ;}e l s e {

re turn true ;}

}

pub l i c func t i on check emai l ( ) {$eml=$th i s−>input−>post ( ’ email ’ ) ;$ r e s u l t=$th i s−>log in model−>ch e c k ema i l e x i s t ( $eml ) ;i f ( $ r e s u l t ) {

echo ” f a l s e ” ;}e l s e {

echo ” true ” ;}

}

//FORGOT PASSWORD CONTROLLERSpub l i c func t i on fo rge t pas sword ( ) {

$th i s−>load−>view ( ’ l o g i n f o r g e t i n d e x ’ ) ;}

pub l i c func t i on do fo rge t ( ) {$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ emai l address ’ , ’ Email Address ’ , ’ r equ i r ed |va l i d ema i l | c a l l b a c k c h e c k ema i l c i e x i s t s ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// $th i s−>index ( ) ;$ th i s−>load−>view ( ’ l o g i n f o r g e t i n d e x ’ ) ;

}e l s e {

$th i s−>load−>he lpe r ( ’ ur l ’ ) ;$ ema i l addre s s= $ POST [ ’ emai l address ’ ] ;$q = $th i s−>db−>query (” s e l e c t ∗ from use r s where ema i l addre s s =’” .

$ema i l addre s s . ” ’”) ;

209

Page 221: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

i f ( $q−>num rows > 0) {$r = $q−>r e s u l t ( ) ;$user=$r [ 0 ] ;$ th i s−>resetpassword ( $user ) ;

}$message = ”Email Sent . P lease check your emai l f o r d e t a i l s . ” ;

i f ( ( i s s e t ( $message ) ) && ( $message != ’ ’ ) ) {echo ’< 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 ep l a c e ( ” . . / l o g i n ”) ;</s c r i p t > ’ ;

}}

}

pr i va t e func t i on resetpassword ( $user ) {da t e d e f au l t t ime z on e s e t ( ’GMT’ ) ;$th i s−>load−>he lpe r ( ’ s t r i ng ’ ) ;$password= random str ing ( ’ alnum ’ , 16) ;$th i s−>db−>where ( ’ username ’ , $user−>username ) ;$th i s−>db−>update ( ’ users ’ , array ( ’ password ’=>MD5( $password ) , ’ conf irm password

’=>MD5( $password ) ) ) ;$ c i = g e t i n s t an c e ( ) ;$c i−>load−>l i b r a r y ( ’ email ’ ) ;$ con f i g [ ’ protoco l ’ ] = ”smtp ” ;$ con f i g [ ’ smtp host ’ ] = ” s s l : // smtp . gmail . com” ;$ con f i g [ ’ smtp port ’ ] = ”465”;$ con f i g [ ’ smtp user ’ ] = ”heasf im . noreply@gmail . com” ;$ con f i g [ ’ smtp pass ’ ] = ” sasablayakothissem2015 ” ;$ con f i g [ ’ charset ’ ] = ”utf −8”;$ con f i g [ ’ mailtype ’ ] = ”html ” ;$ con f i g [ ’ newline ’ ] = ”\ r\n ” ;

$c i−>email−> i n i t i a l i z e ( $ con f i g ) ;

$c i−>email−>from ( ’ heasf im . noreply@gmail . com ’ , ’HEAS:FIM’ ) ;// $ l i s t = array ( ’ xxx@gmail . com ’ ) ;$c i−>email−>to ( $user−>ema i l addre s s ) ;

// $th i s−>email−>r e p l y t o ( ’my−email@gmail . com ’ , ’My Email ’ ) ;$c i−>email−>sub j e c t ( ’ Password Reset ’ ) ;$c i−>email−>message ( ’You have requested a new password . Here i s your new password : ’ .

$password ) ;$c i−>email−>send ( ) ;

}

pub l i c func t i on c h e c k ema i l c i e x i s t s ( ) {$eml=$th i s−>input−>post ( ’ emai l address ’ ) ;$ r e s u l t=$th i s−>log in model−>ch e c k ema i l e x i s t ( $eml ) ;i f ( $ r e s u l t ) {

re turn true ;}e l s e {

$th i s−>f o rm va l ida t i on−>se t message ( FUNCTION , ’E−mail Address doesnot e x i s t . ’ ) ;

r e turn f a l s e ;}

}

}

?>

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;s e s s i o n s t a r t ( ) ; //we need to c a l l PHP’ s s e s s i o n ob j e c t to ac c e s s i t through CI

c l a s s Logout extends CI Cont ro l l e r {

f unc t i on c on s t r u c t ( ) {parent : : c o n s t r u c t ( ) ;

}

//LOGOUTfunct i on logout ( ) {

$th i s−>s e s s i on−>unse t use rdata ( ’ l ogged in ’ ) ;s e s s i o n d e s t r o y ( ) ;r e d i r e c t ( ’ l og in ’ , ’ r e f r e sh ’ ) ;

}

}

?>

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;

c l a s s Ver i fyLog in extends CI Cont ro l l e r {

f unc t i on c on s t r u c t ( ) {parent : : c o n s t r u c t ( ) ;$ th i s−>load−>model ( ’ log in model ’ , ’ ’ ,TRUE) ;

}

f unc t i on index ( ) {//This method w i l l have the c r e d e n t i a l s v a l i d a t i on$th i s−>load−>l i b r a r y ( ’ f o rm va l ida t i on ’ ) ;

210

Page 222: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ username ’ , ’Username ’ , ’ tr im | r equ i r ed |xs s c l ean ’ ) ;

$ th i s−>f o rm va l ida t i on−>s e t r u l e s ( ’ password ’ , ’ Password ’ , ’ tr im | r equ i r ed |x s s c l e an | ca l lback check database ’ ) ;

i f ( $ th i s−>f o rm va l ida t i on−>run ( ) == FALSE) {// F ie ld va l i d a t i on f a i l e d . User r e d i r e c t e d to l o g i n page// $th i s−>load−>view ( ’ l og in index ’ ) ;$ th i s−>load−>he lpe r ( array ( ’ form ’ ) ) ;$ th i s−>load−>he lpe r ( ’ captcha ’ ) ;$va l s = array (

’ img path ’ => ’ . / captcha / ’ ,’ img url ’ => ’ https :// a g i l a .upm. edu . ph/˜ pjd izon /FIM/captcha / ’

) ;$cap = crea t e captcha ( $va l s ) ;$data = array (

’ captcha time ’ => $cap [ ’ time ’ ] ,’ i p addre s s ’ => $th i s−>input−>i p add r e s s ( ) ,’word ’ => $cap [ ’ word ’ ]

) ;$ th i s−>s e s s i on−>s e t u s e rda t a ( $data ) ;$data [ ’ cap img ’ ]= $cap [ ’ image ’ ] ;$ th i s−>load−>view ( ’ l og in index ’ , $data ) ;

}e l s e {

//Go to p r i va t e arear e d i r e c t ( ’ home ’ , ’ r e f r e sh ’ ) ;

}}

f unc t i on check database ( $password ) {// F ie ld va l i d a t i on succeeded . Val idate aga in s t database$username = $th i s−>input−>post ( ’ username ’ ) ;$ f i r s t name = $th i s−>input−>post ( ’ f i r s t name ’ ) ;$use r type = $th i s−>input−>post ( ’ user type ’ ) ;

// query the database$ r e s u l t = $th i s−>log in model−>l o g i n ( $username , $password ) ;

i f ( $ r e s u l t ) {$ s e s s a r r a y = array ( ) ;f o r each ( $ r e s u l t as $row ) {

$ s e s s a r r a y = array (’ u s e r id ’ => $row−>use r id ,’ username ’ => $row−>username ,’ f i r s t name ’ => $row−>f i r s t name ,’ middle name ’ => $row−>middle name ,’ last name ’ => $row−>last name ,’ user type ’ => $row−>user type ,’ emai l address ’ => $row−>emai l address ,’ gender ’ => $row−>gender ,’ birthday ’ => $row−>birthday ,’ s tatus ’ => $row−>s t a tu s) ;

}i f ( $row−>s t a tu s !=”Deact ivated ”) {

$th i s−>s e s s i on−>s e t u s e rda t a ( ’ l ogged in ’ , $ s e s s a r r a y ) ;re turn TRUE;

}

e l s e {$th i s−>f o rm va l ida t i on−>se t message ( ’ check database ’ , ’Your account

might be deact ivated at the moment . ’ ) ;r e turn f a l s e ;

}}

e l s e {$th i s−>f o rm va l ida t i on−>se t message ( ’ check database ’ , ’ I nva l i d

Username or Password . ’ ) ;r e turn f a l s e ;

}}

}

?>

B..3 Models

<?php

c l a s s Home Admin Model extends CI Model {//USER SEARCH MODEL/S

func t i on GetAutocomplete ( $opt ions = array ( ) ) {$th i s−>db−>s e l e c t ( ’ u s e r id , username , f i r s t name , middle name , last name ,

user type , emai l address , gender , birthday ’ ) ;$ th i s−>db−>l i k e ( ’ username ’ , $opt ions [ ’ keyword ’ ] , ’ a f t e r ’ ) ;

$query = $th i s−>db−>get ( ’ users ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

f unc t i on g e t s e a r ch ( ) {$match = $th i s−>input−>post ( ’ search ’ ) ;$ th i s−>db−>l i k e ( ’ u s e r id ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ username ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ f i r s t name ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ middle name ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ last name ’ , $match ) ;

211

Page 223: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$th i s−>db−>o r l i k e ( ’ user type ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ emai l address ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ gender ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ birthday ’ , $match ) ;$th i s−>db−>order by ( ’ u s e r id ’ , ’ desc ’ ) ;

$query = $th i s−>db−>get ( ’ users ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//ADD USER MODEL/Sfunc t i on proce s s ( ) {$username = $th i s−>input−>post ( ’ username ’ ) ;

$password = $th i s−>input−>post ( ’ password ’ ) ;$conf i rm password = $th i s−>input−>post ( ’ conf irm password ’ ) ;$ f i r s t name = $th i s−>input−>post ( ’ f i r s t name ’ ) ;$middle name = $th i s−>input−>post ( ’ middle name ’ ) ;$ last name = $th i s−>input−>post ( ’ last name ’ ) ;$gender = $th i s−>input−>post ( ’ genderRadio ’ ) ;$use r type = $th i s−>input−>post ( ’ userTypeRadio ’ ) ;$ ema i l addre s s = $th i s−>input−>post ( ’ emai l address ’ ) ;$birthday = $th i s−>input−>post ( ’ b i r thdate ’ ) ;

$data = array (’ username ’ => $username ,

’ password ’ => MD5( $password ) ,’ conf irm password ’ => MD5( $conf irm password ) ,’ f i r s t name ’ => $ f i r s t name ,’ middle name ’ => $middle name ,’ last name ’ => $last name ,’ gender ’ => $gender ,’ user type ’ => $user type ,’ emai l address ’ => $emai l address ,’ birthday ’ => $birthday

) ;$th i s−>db−>i n s e r t ( ’ users ’ , $data ) ;

}

pub l i c func t i on c h e c k u s e r e x i s t ( $usr ) {$th i s−>db−>where (” username ” , $usr ) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

pub l i c func t i on ch e ck ema i l e x i s t ( $eml ) {$th i s−>db−>where (” ema i l addre s s ” , $eml ) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

//DELETE USER MODELpub l i c func t i on d e l u s e r ( $username ) {

$th i s−>db−>where ( ’ username ’ , $username ) ;$th i s−>db−>de l e t e ( ’ users ’ ) ;

}

//EDIT USER MODELpub l i c func t i on update user ( $username , $data ) {

$th i s−>db−>where ( ’ username ’ , $username ) ;$th i s−>db−>update ( ’ users ’ , $data ) ;

}

f unc t i on g e t u s e r ( $username ) {$th i s−>db−>s e l e c t ( ’ username , f i r s t name , middle name , last name , user type ,

emai l address , gender , birthday , s tatus ’ ) ;$ th i s−>db−>where ( ’ username ’ , $username ) ;$query = $th i s−>db−>get ( ’ users ’ ) ;

r e turn $query−>row array ( ) ;// return $query−>r e s u l t ( ) ;

}

//EDIT PROFILE MODELpub l i c func t i on upda t e p r o f i l e ( $username , $data ) {

$th i s−>db−>where ( ’ username ’ , $username ) ;$th i s−>db−>update ( ’ users ’ , $data ) ;

}

//EDIT PASSWORD MODELpub l i c func t i on update password ( $username , $data ) {

$th i s−>db−>where ( ’ username ’ , $username ) ;$th i s−>db−>update ( ’ users ’ , $data ) ;

}

pub l i c func t i on che ck o ld pa s swo rd ex i s t ($opwd) {$th i s−>db−>where (” password ” , $opwd) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}

212

Page 224: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

e l s e {re turn f a l s e ;

}}

}

?>

<?php

c l a s s Home Cmanager Model extends CI Model {

pub l i c func t i on c h e c k u s e r e x i s t ( $usr ) {$th i s−>db−>where (” username ” , $usr ) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

pub l i c func t i on ch e ck ema i l e x i s t ( $eml ) {$th i s−>db−>where (” ema i l addre s s ” , $eml ) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

//EDIT PROFILE MODELpub l i c func t i on upda t e p r o f i l e ( $username , $data ) {

$th i s−>db−>where ( ’ username ’ , $username ) ;$th i s−>db−>update ( ’ users ’ , $data ) ;

}

//EDIT PASSWORD MODELpub l i c func t i on update password ( $username , $data ) {

$th i s−>db−>where ( ’ username ’ , $username ) ;$th i s−>db−>update ( ’ users ’ , $data ) ;

}

pub l i c func t i on che ck o ld pa s swo rd ex i s t ($opwd) {$th i s−>db−>where (” password ” , $opwd) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

//ADD HEALTH TIP MODELfunc t i on p r o c e s s h e a l t h t i p ( ) {$h ea l t h t i p = $th i s−>input−>post ( ’ h ea l th t i p ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;$data [ ’ h ea l th t i p ’ ] = $hea l t h t i p ;$data [ ’ post date ’ ] = date ( ’ y−m−d ’ ) ;$ th i s−>db−>i n s e r t ( ’ h e a l t h t i p s ’ , $data ) ;

}

e l s eecho ( ’ Se s s i on Timeout . ’ ) ;

}

//DELETE HEALTH TIP MODELpub l i c func t i on d e l h e a l t h t i p ( $ h e a l t h t i p i d ) {

// $th 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 ) ;$ th i s−>db−>de l e t e ( ’ h e a l t h t i p s ’ , array ( ’ 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 ITEMpub l i c func t i on c h e c k f e l i t em e x i s t ( $food name ) {

$th i s−>db−>where (” food name ” , $food name ) ;$query=$th i s−>db−>get (” f o od e x chang e l i s t ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

f unc t i on p r o c e s s f e l i t em ( ) {i f ( i s s e t ($ POST [ ’ l i s t g r oupo th e r ’ ] , $ POST [ ’ food groupother ’ ] , $ POST [ ’

f ood group categoryother ’ ] ) ) {$ l i s t g r o up = $th i s−>input−>post ( ’ l i s t g r oupo th e r ’ ) ;

$ food group = $th i s−>input−>post ( ’ food groupother ’ ) ;$ food group category = $th i s−>input−>post ( ’ f ood group categoryother ’ ) ;

} e l s e {

213

Page 225: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ l i s t g r o up = $th i s−>input−>post ( ’ l i s t g r oup ’ ) ;$ food group = $th i s−>input−>post ( ’ food group ’ ) ;$ food group category = $th i s−>input−>post ( ’ food group category ’ ) ;

}

$food name = $th i s−>input−>post ( ’ food name ’ ) ;$measure = $th i s−>input−>post ( ’ measure ’ ) ;$carbohydrate = $th i s−>input−>post ( ’ carbohydrate ’ ) ;$pro te in = $th i s−>input−>post ( ’ prote in ’ ) ;$ f a t = $th i s−>input−>post ( ’ fat ’ ) ;$energy = $th i s−>input−>post ( ’ energy ’ ) ;$we ight as purchased = $th i s−>input−>post ( ’ we ight as purchased ’ ) ;$we i gh t ed i b l e po r t i on = $th i s−>input−>post ( ’ we i gh t ed ib l e po r t i on ’ ) ;

$data = array (’ l i s t g r oup ’ => $ l i s t g r oup ,

’ food group ’ => $food group ,’ food group category ’ => $ food group category ,’ food name ’ => $food name ,’measure ’ => $measure ,’ carbohydrate ’ => $carbohydrate ,’ prote in ’ => $prote in ,’ fat ’ => $fat ,’ energy ’ => $energy ,’ we ight as purchased ’ => $weight as purchased ,’ we i gh t ed ib l e po r t i on ’ => $we i gh t ed i b l e po r t i on

) ;$th i s−>db−>i n s e r t ( ’ f o od ex change l i s t ’ , $data ) ;

}

//DELETE FEL ITEMpub l i c func t i on d e l f e l i t em ( $ f o o d e x c h an g e l i s t i d ) {

// $th 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 ) ;$ th i s−>db−>de l e t e ( ’ f o od ex change l i s t ’ , array ( ’ f o od e x chang e l i s t i d ’ =>

$ f o o d e x c h an g e l i s t i d ) ) ;}

f unc t i on g e t s e a r c h f e l ( ) {$match = $th i s−>input−>post ( ’ s e a r c h f e l ’ ) ;$ th i s−>db−>l i k e ( ’ l i s t g r oup ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ food group ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ food group category ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ food name ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ measure ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ carbohydrate ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ prote in ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ fat ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ energy ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ we ight as purchased ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ we i gh t ed ib l e po r t i on ’ , $match ) ;

$query = $th i s−>db−>get ( ’ f o od ex change l i s t ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

f unc t i on g e t s e a r ch h t ( ) {$match = $th i s−>input−>post ( ’ search ht ’ ) ;$ th i s−>db−>l i k e ( ’ h ea l th t i p ’ , $match ) ;$th i s−>db−>order by ( ’ h e a l t h t i p i d ’ , ’ desc ’ ) ;

$query = $th i s−>db−>get ( ’ h e a l t h t i p s ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//VIEW CREATED RECIPES MODELfunc t i on p r o c e s s v i ew c r e a t e d r e c i p e s ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

/∗ $th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes o , i n g r ed i e n t s i ’ ) ;$ th i s−>db−>where ( ’ o . u s e r id ’ , $u s e r i d ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = i . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

$th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ recommended recipes ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$ th i s−>db−>order by ( ’ recommended recipe id ’ , ’ desc ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

//EDIT CREATED RECIPEfunc t i on g e t c r e a t e d r e c i p e ( $recommended rec ipe id ) {

$th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ , r .∗ ’ ) ;$ th i s−>db−>from ( ’ recommended recipes o , ingredients recommended i ,

recipe images recommended r ’ ) ;$ th i s−>db−>where ( ’ o . recommended recipe id ’ , $recommended rec ipe id ) ;$ th i s−>db−>where ( ’ o . recommended rec ipe id = i . recommended recipe id ’ ) ;$ th i s−>db−>where ( ’ o . recommended rec ipe id = r . recommended recipe id ’ ) ;$query = $th i s−>db−>get ( ) ;

// return $query−>row array ( ) ;r e turn $query−>r e s u l t ( ) ;

214

Page 226: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}

//UPDATE RECIPE MODELpub l i c func t i on update r e c ipe ( $recommended recipe id , $data , $data2 ) {

$th i s−>db−>where ( ’ recommended recipe id ’ , $recommended rec ipe id ) ;$ th i s−>db−>update ( ’ recommended recipes ’ , $data ) ;// $own rec ipe id = $th i s−>db−>i n s e r t i d ( ) ;

// th i s−>db−>update ( ’ i ng r ed i en t s ’ , $data2 ) ;f o r ( $ i = 0 ; $ i < count ( $data2 [ ’ food name ’ ] ) ; $ i++) {

$data3 = array (’ food name ’=>$data2 [ ’ food name ’ ] [ $ i ] ,’ food group ’=>$data2 [ ’ food group ’ ] [ $ i ] ,’ measure ’=>$data2 [ ’ measure ’ ] [ $ i ] ,’ s e r v i n g s i z e ’=>$data2 [ ’ s e r v i n g s i z e ’ ] [ $ i ] ,

) ;i f ( $data2 [ ’ i n g r ed i en t i d ’ ] [ $ i ] == nu l l | | $data2 [ ’ i n g r ed i en t i d ’ ] [ $ i ]

== ””) {$data3 [ ’ recommended recipe id ’ ] = $recommended rec ipe id ;$th i s−>db−>i n s e r t ( ’ ingredients recommended ’ , $data3 ) ;

} e l s e {$th i s−>db−>where ( ’ i n g r ed i en t i d ’ , $data2 [ ’ i n g r ed i en t i d ’ ] [ $ i ] )

;$ th i s−>db−>update ( ’ ingredients recommended ’ , $data3 ) ;

}}

}

//VIEW RECIPEfunc t i on g e t r e c i p e c on t e n t s ( $recommended rec ipe id ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

/∗ $th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes o , i n g r ed i e n t s i ’ ) ;$ th i s−>db−>where ( ’ o . u s e r id ’ , $u s e r i d ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = i . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

/∗ $th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ i ng r ed i en t s ’ ) ;$ th i s−>db−>where (” own rec ipe id ” , $own rec ipe id ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

$th i s−>db−>s e l e c t ( ’ r .∗ , i .∗ , c .∗ ’ ) ;$ th i s−>db−>from ( ’ recommended recipes r , ingredients recommended i ,

recipe images recommended c ’ ) ;$ th i s−>db−>where ( ’ i . recommended recipe id ’ , $recommended rec ipe id ) ;$ th i s−>db−>where ( ’ i . recommended rec ipe id = r . recommended recipe id ’ ) ;$ th i s−>db−>where ( ’ c . recommended rec ipe id = r . recommended recipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

//DELETE CREATED RECIPEpub l i c func t i on d e l c r e a t e d r e c i p e ( $recommended rec ipe id ) {

// $th 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 ) ;$ th i s−>db−>de l e t e ( ’ recommended recipes ’ , array ( ’ recommended recipe id ’ =>

$recommended rec ipe id ) ) ;$ th i s−>db−>de l e t e ( ’ ingredients recommended ’ , array ( ’ recommended recipe id ’ =>

$recommended rec ipe id ) ) ;$ th i s−>db−>de l e t e ( ’ recipe images recommended ’ , array ( ’ recommended recipe id ’

=> $recommended rec ipe id ) ) ;}

//DELETE INGREDIENTSpub l i c func t i on d e l i n g r e d i e n t ( $ i n g r e d i e n t i d ) {

$th i s−>db−>de l e t e ( ’ ingredients recommended ’ , array ( ’ i n g r ed i en t i d ’ =>$ i n g r e d i e n t i d ) ) ;

}

//ADD RECIPE MODELfunc t i on p ro c e s s add r e c i p e ( $data3 ){// $hea l th cond i t i on = $th i s−>input−>post ( ’ h ea l th cond i t i on ’ ) ;$h ea l th cond i t i on = implode (” ,” , $th i s−>input−>post ( ’ h ea l th cond i t i on ’ ) ) ;$meal type = $th i s−>input−>post ( ’ meal type ’ ) ;$rec ipe name = $th i s−>input−>post ( ’ recipe name ’ ) ;$ s e rv ing sugg = $th i s−>input−>post ( ’ s e rv ing sugg ’ ) ;$preparat i on procedure = $th i s−>input−>post ( ’ preparat ion procedure ’ ) ;$ c a l o r i e s = $th i s−>input−>post ( ’ c a l o r i e s ’ ) ;$carbohydrate = $th i s−>input−>post ( ’ carbohydrate ’ ) ;$pro te in = $th i s−>input−>post ( ’ prote in ’ ) ;$ f a t = $th i s−>input−>post ( ’ fat ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;

$data [ ’ u s e r id ’ ] = $u s e r i d ;$data [ ’ h ea l th cond i t i on ’ ] = $hea l th cond i t i on ;$data [ ’ meal type ’ ] = $meal type ;$data [ ’ recipe name ’ ] = $rec ipe name ;$data [ ’ s e rv ing sugg ’ ]= $se rv ing sugg ;$data [ ’ preparat ion procedure ’ ] = $preparat i on procedure ;

215

Page 227: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ c a l o r i e s ’ ] = $ c a l o r i e s ;$data [ ’ carbohydrate ’ ] = $carbohydrate ;$data [ ’ prote in ’ ] = $prote in ;$data [ ’ fat ’ ] = $ f a t ;

$ th i s−>db−>i n s e r t ( ’ recommended recipes ’ , $data ) ;

$recommended rec ipe id = $th i s−>db−>i n s e r t i d ( ) ;

i f ( i s s e t ($ POST [ ’ i ng r ed i en t s ’ ] , $ POST [ ’ food group ’ ] , $ POST [ ’ingred ient measure ’ ] , $ POST [ ’ i ng r ed i en t quant i t y ’ ] ) ){

f o r ( $ i =0; $i<count ($ POST [ ’ i ng r ed i en t s ’ ] ) ; $ i++) {$ i ng r ed i en t s = $ POST [ ’ i ng r ed i en t s ’ ] [ $ i ] ;$ food group = $ POST [ ’ food group ’ ] [ $ i ] ;$ ingred i ent measure =$ POST [ ’ ingred ient measure ’ ] [ $ i ] ;$ i n g r ed i en t quan t i t y = $ POST [ ’ i ng r ed i en t quant i t y ’ ] [

$ i ] ;$data2 [ ’ recommended recipe id ’ ] =

$recommended rec ipe id ;$data2 [ ’ food name ’ ] = $ i ng r ed i en t s ;$data2 [ ’ food group ’ ] = $food group ;$data2 [ ’ measure ’ ] = $ ingred i ent measure ;$data2 [ ’ s e r v i n g s i z e ’ ] = $ ing r ed i en t quan t i t y ;/∗$counts = ar ray count va lue s ( $food group ) ;echo $counts [ ’ Vegetable ’ ] ;∗/$th i s−>db−>i n s e r t ( ’ ingredients recommended ’ , $data2 ) ;

}}

$data3 [ ’ recommended recipe id ’ ] = $recommended rec ipe id ;

$th i s−>db−>i n s e r t ( ’ recipe images recommended ’ , $data3 ) ;

}e l s e

echo ” Ses s i on Timeout ” ;}

//ADD INGREDIENT AUTOCOMPLETEfunc t i on GetAutocomplete ( $opt ions = array ( ) ) {

$th i s−>db−>s e l e c t ( ’ food group , food name , we i gh t ed ib l e po r t i on , energy ,carbohydrate , prote in , fat ’ ) ;

$ th i s−>db−>l i k e ( ’ food name ’ , $opt ions [ ’ keyword ’ ] , ’ a f t e r ’ ) ;$query = $th i s−>db−>get ( ’ f o od ex change l i s t ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//SEARCH FOR MEAL MODELfunc t i on ge t s ea r ch mea l ( ) {

$match = $th i s−>input−>post ( ’ search meal ’ ) ;$ th i s−>db−>l i k e ( ’ recommended recipe id ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ u s e r id ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ h ea l th cond i t i on ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ meal type ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ recipe name ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ s e rv ing sugg ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ preparat ion procedure ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ c a l o r i e s ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ carbohydrate ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ prote in ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ fat ’ , $match ) ;$th i s−>db−>order by ( ’ recommended recipe id ’ , ’ desc ’ ) ;$query = $th i s−>db−>get ( ’ recommended recipes ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//ADD MEALfunc t i on process addmeal ( $recommended rec ipe id ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d = $ s e s s i on da t a [ ’ u s e r id ’ ] ;$meal group = $th i s−>input−>post ( ’ meal group ’ ) ;$ r e co rd date = $th i s−>input−>post ( ’ r ecord date ’ ) ;

$data [ ’ u s e r id ’ ] = $u s e r i d ;$data [ ’ recommended recipe id ’ ] = $recommended rec ipe id ;$data [ ’ meal group ’ ] = $meal group ;$data [ ’ meal group ’ ] = $meal group ;$data [ ’ r ecord date ’ ] = $reco rd date ;

$th i s−>db−>i n s e r t ( ’ recommended daily meals ’ , $data ) ;}e l s e

echo ” Ses s i on Timeout ” ;}

//DELETE MEALpub l i c func t i on de l mea l ( $recommended dai ly meal id ) {

// $th 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 ) ;$ th i s−>db−>de l e t e ( ’ recommended daily meals ’ , array ( ’ recommended dai ly meal id ’

=> $recommended dai ly meal id ) ) ;}

//VIEW DAILY MEALS BY DATE MODELpub l i c func t i on show data by date ( $ r eco rd date ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;

216

Page 228: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;// $data [ ’ u s e r id ’ ] = $u s e r i d ;// $cond i t i on = ” reco rd date =” . ” ’” . $ r e co rd date . ” ’ ” ;

$ th i s−>db−>s e l e c t ( ’ d .∗ , r .∗ ’ ) ;$ th i s−>db−>from ( ’ recommended dai ly meals d , recommended recipes r ’ ) ;$ th i s−>db−>where (”d . u s e r i d ” , $u s e r i d ) ;$ th i s−>db−>where ( ’ d . record date ’ , $ r e co rd date ) ;$ th i s−>db−>where ( ’ d . recommended rec ipe id = r . recommended recipe id ’ ) ;$ th i s−>db−>order by ( ’ meal group ’ , ’ asc ’ ) ;

$query = $th i s−>db−>get ( ) ;

i f ( $query−>num rows ( ) > 0) {re turn $query−>r e s u l t ( ) ;

} e l s e {re turn f a l s e ;

}}

}

//EDIT FEL MODELpub l i c func t i on upda t e f e l ( $ f o od ex chang e l i s t i d , $data ) {

$th i s−>db−>where ( ’ f o od e x chang e l i s t i d ’ , $ f o o d e x c h an g e l i s t i d ) ;$ th i s−>db−>update ( ’ f o od ex change l i s t ’ , $data ) ;

}

f unc t i on g e t f e l e d i t ( $ f o o d e x c h an g e l i s t i d ) {$th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>where ( ’ f o od e x chang e l i s t i d ’ , $ f o o d e x c h an g e l i s t i d ) ;$query = $th i s−>db−>get ( ’ f o od ex change l i s t ’ ) ;

r e turn $query−>row array ( ) ;// return $query−>r e s u l t ( ) ;

}

//EDIT HT MODELpub l i c func t i on update ht ( $h e a l t h t i p i d , $data ) {

$th 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 ) ;$ th i s−>db−>update ( ’ h e a l t h t i p s ’ , $data ) ;

}

f unc t i on g e t h t e d i t ( $ h e a l t h t i p i d ) {$th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th 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 ) ;$query = $th i s−>db−>get ( ’ h e a l t h t i p s ’ ) ;

r e turn $query−>row array ( ) ;// return $query−>r e s u l t ( ) ;

}

//GET FEL LIST GROUPpub l i c func t i on g e t l i s t g r o u p ( ) {

$th i s−>db−>s e l e c t ( ’ l i s t g r oup ’ ) ;// $th i s−>db−>d i s t i n c t ( ) ;$query = $th i s−>db−>get ( ’ f o od ex change l i s t ’ ) ;f o r each ( $query−>r e s u l t a r r a y ( ) as $row ){

$data [ $row [ ’ l i s t g r oup ’ ] ]= $row [ ’ l i s t g r oup ’ ] ;}

// $data [ ’ Other ’ ] = ’Other ’ ;r e turn $data ;}

//GET FEL FOOD GROUP BY LIST GROUPpub l i c func t i on ge t f ood group ( $ l i g r oup=s t r i n g ){

$th i s−>db−>s e l e c t ( ’ l i s t g r oup , food group ’ ) ;$ th i s−>db−>where ( ’ l i s t g r oup ’ , $ l i g r oup ) ;

$th i s−>db−>d i s t i n c t ( ) ;$query = $th i s−>db−>get ( ’ f o od ex change l i s t ’ ) ;r e turn $query ;

}

//GET FEL FOOD GROUP CATEGORY BY LIST GROUPpub l i c func t i on ge t f ood g roup ca t ego ry ( $ l i g r oup=s t r i n g ){

$th i s−>db−>s e l e c t ( ’ l i s t g r oup , food group category ’ ) ;$ th i s−>db−>where ( ’ l i s t g r oup ’ , $ l i g r oup ) ;

$th i s−>db−>d i s t i n c t ( ) ;$query = $th i s−>db−>get ( ’ f o od ex change l i s t ’ ) ;r e turn $query ;

}}

?>

<?php

c l a s s Home User Model extends CI Model {f unc t i on c on s t r u c t ( )

{// Cal l the Model cons t ruc to rparent : : c o n s t r u c t ( ) ;

}

pub l i c func t i on c h e c k u s e r e x i s t ( $usr ) {$th i s−>db−>where (” username ” , $usr ) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;

217

Page 229: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}e l s e {

re turn f a l s e ;}

}

pub l i c func t i on ch e ck ema i l e x i s t ( $eml ) {$th i s−>db−>where (” ema i l addre s s ” , $eml ) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

//EDIT PROFILE MODELpub l i c func t i on upda t e p r o f i l e ( $username , $data ) {

$th i s−>db−>where ( ’ username ’ , $username ) ;$th i s−>db−>update ( ’ users ’ , $data ) ;

}

//EDIT PASSWORD MODELpub l i c func t i on update password ( $username , $data ) {

$th i s−>db−>where ( ’ username ’ , $username ) ;$th i s−>db−>update ( ’ users ’ , $data ) ;

}

pub l i c func t i on che ck o ld pa s swo rd ex i s t ($opwd) {$th i s−>db−>where (” password ” , $opwd) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

//SEARCH FOOD EXCHANGE LIST MODELfunc t i on g e t s e a r c h f e l ( ) {

$match = $th i s−>input−>post ( ’ s e a r c h f e l ’ ) ;$ th i s−>db−>l i k e ( ’ l i s t g r oup ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ food group ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ food group category ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ food name ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ measure ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ carbohydrate ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ prote in ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ fat ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ energy ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ we ight as purchased ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ we i gh t ed ib l e po r t i on ’ , $match ) ;

$query = $th i s−>db−>get ( ’ f o od ex change l i s t ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//HEALTHTIPS FEED MODEL/∗ pub l i c func t i on count ht ( ) {re turn count ( $th i s−>g e t s e a r ch h t ( ) ) ;

}

pub l i c func t i on g e t s e a r c h h t r e t ( ) {$params = fun c g e t a r g s ( ) ;$ l im i t = $params [ 0 ] [ ’ l im i t ’ ] ? $params [ 0 ] [ ’ l im 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 ;

$query = $th i s−>g e t s e a r ch h t ( ) ;$ r e t a r r ay = array ( ) ;

f o r ( $ i = 0 ; $ i < $ l im i t ; $ i ++) {i f ( $ o f f s e t < count ( $query ) ) {

$ r e t a r r ay [ ] = $query [ $ o f f s e t ] ;$ o f f s e t ++;

}}

re turn $ r e t a r r ay ;}∗/

func t i on g e t s e a r ch h t ( ) {$th i s−>db−>order by (” pos t date ” , ” desc ”) ;// $th i s−>db−>l im i t (5 ) ;

$query = $th i s−>db−>get ( ’ h e a l t h t i p s ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//ACHIEVEMENTS FEED MODELfunc t i on ge t s ea r ch ach i evement s ( ) {

$th i s−>db−>order by (” shared ach ievement id ” , ” desc ”) ;$th i s−>db−>l im i t (5 ) ;

$query = $th i s−>db−>get ( ’ shared achievements ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//ADD FP INFO MODELfunc t i on proce s s add fp ( ) {

218

Page 230: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$goa l we ight = $th i s−>input−>post ( ’ goa l we ight ’ ) ;$cur rent we ight = $th i s−>input−>post ( ’ current we ight ’ ) ;$he ight = $th i s−>input−>post ( ’ height ’ ) ;

// $hea l th cond i t i on = $th i s−>input−>post ( ’ h ea l th cond i t i on ’ ) ;$h ea l th cond i t i on = implode (” ,” , $th i s−>input−>post ( ’ h ea l th cond i t i on ’ ) ) ;

// p r i n t r ( $hea l th cond i t i on ) ;// d i e ( ) ;

$ r e co rd date = $th i s−>input−>post ( ’ r ecord date ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;

$ th i s−>db−>s e l e c t ( ’ birthday ’ ) ;$ th i s−>db−>from ( ’ users ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$query b i r thday = $th i s−>db−>get ( ) ;$query birthday−>r e s u l t ( ) ;f o r each ( $query birthday−>r e s u l t ( ) as $row ) {

// echo $row−>birthday ;$birthday = $row−>birthday ;// echo $birthday ;

}

$th i s−>db−>s e l e c t ( ’ gender ’ ) ;$ th i s−>db−>from ( ’ users ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$query gender = $th i s−>db−>get ( ) ;$query gender−>r e s u l t ( ) ;f o r each ( $query gender−>r e s u l t ( ) as $row ) {

// echo $row−>birthday ;$gender = $row−>gender ;// echo $gender ;

}

i f ( $gender ==”Male ”){$age = $reco rd date − $birthday ;$ c a l o r i e l i m i t = 66 + (13 . 7 ∗ $cur rent we ight ) + (5 ∗ $he ight )

− ( 6 . 8 ∗ $age ) ;$ ca rbohydra t e l im i t = 0.65 ∗ $ c a l o r i e l i m i t ;$ p r o t e i n l im i t = 0.25 ∗ $ c a l o r i e l i m i t ;$ f a t l im i t = 0.70 ∗ $ c a l o r i e l i m i t ;

} e l s e {$age = $reco rd date − $birthday ;$ c a l o r i e l i m i t = 655 + (9 . 6 ∗ $cur rent we ight ) + (1 . 7 ∗

$he ight ) − ( 4 . 7 ∗ $age ) ;$ ca rbohydra t e l im i t = (0 . 65 ∗ $ c a l o r i e l i m i t ) / 4 ;$ p r o t e i n l im i t = (0 . 25 ∗ $ c a l o r i e l i m i t ) / 4 ;$ f a t l im i t = (0 . 70 ∗ $ c a l o r i e l i m i t ) / 9 ;

}

$data [ ’ u s e r id ’ ] = $u s e r i d ;$data [ ’ goa l we ight ’ ] = $goa l we ight ;$data [ ’ current we ight ’ ] = $cur rent we ight ;$data [ ’ height ’ ] = $he ight ;$data [ ’ c a l o r i e l im i t ’ ] = $ c a l o r i e l i m i t ;$data [ ’ ca rbohydrate l im i t ’ ] = $ca rbohydra t e l im i t ;$data [ ’ p r o t e i n l im i t ’ ] = $p r o t e i n l im i t ;$data [ ’ f a t l im i t ’ ] = $ f a t l im i t ;$data [ ’ r ecord date ’ ] = $reco rd date ;$th i s−>db−>i n s e r t ( ’ f i t n e s s p r o f i l e ’ , $data ) ;

$ f i t n e s s i n f o i d = $th i s−>db−>i n s e r t i d ( ) ;$data2 [ ’ h ea l th cond i t i on ’ ] = $hea l th cond i t i on ;$data2 [ ’ u s e r id ’ ] = $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 ecord date ’ ] = $reco rd date ;/∗ i f ( i s s e t ($ POST [ ’ hea l th cond i t i on ’ ] ) ){

f o r ( $ i =0; $i<count ($ POST [ ’ hea l th cond i t i on ’ ] ) ; $ i++) {$hea l th cond i t i on = $ POST [ ’ hea l th cond i t i on ’ ] [ $ i ] ;$data2 [ ’ u s e r id ’ ] = $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 ea l th cond i t i on ’ ] = $hea l th cond i t i on ;$data2 [ ’ r ecord date ’ ] = $reco rd date ;∗/

$th i s−>db−>i n s e r t ( ’ h ea l th cond i t i on s ’ , $data2 ) ;/∗}

}∗/}

e l s eecho ” Ses s i on Timeout ” ;

}

pub l i c func t i on c h e c k f p e x i s t ( $ r e c da t e ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;// $data [ ’ u s e r id ’ ] = $u s e r i d ;

}

$th i s−>db−>where (” r e co rd date ” , $ r e c da t e ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$query=$th i s−>db−>get (” f i t n e s s p r o f i l e ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;

219

Page 231: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}e l s e {

re turn f a l s e ;}

}

//VIEW FP INFO MODELfunc t i on proc e s s v i ew fp ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

/∗ $th i s−>db−>order by (” r e co rd date ” , ” desc ”) ;// $th i s−>db−>l im i t (1 ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$query = $th i s−>db−>get ( ’ f i t n e s s p r o f i l e ’ ) ;r e turn $query−>r e s u l t ( ) ;

$ th i s−>db−>s e l e c t ( ’ h ea l th cond i t i on s ’ ) ;$ th i s−>db−>from ( ’ hea l th cond i t i on s ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$query = $th i s−>db−>get ( ) ;r e turn $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 hea l t h c ond 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∗/$th i s−>db−>s e l e c t ( ’ f .∗ , h .∗ ’ ) ;$ th 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 ond i t i o n s h ’ ) ;$ th i s−>db−>where (” f . u s e r i d ” , $u s e r i d ) ;$ th i s−>db−>where ( ’ f . u s e r i d = h . u s e r id ’ ) ;$ th 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 ’ ) ;$ th i s−>db−>order by ( ’ f . r ecord date ’ , ’ desc ’ ) ;

$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

//DELETE FITNESS PROFILE MODELpub l i c func t i on 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 ) {

// $th 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 ) ;$ th i s−>db−>de l e t e ( ’ f i t n e s s p r o f i l e ’ , array ( ’ 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 ) ) ;$ th i s−>db−>de l e t e ( ’ h ea l th cond i t i on s ’ , array ( ’ 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 ) ) ;}

//WEIGHT GRAPH CHART MODELfunc t i on ge t we ightcha r t da ta ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

$th i s−>db−>s e l e c t ( ’ r ecord date , current we ight , goa l we ight ’ ) ;$ th i s−>db−>from ( ’ f i t n e s s p r o f i l e ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$ th i s−>db−>order by (” r e co rd date ” , ’ asc ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

//SHARE ACHIEVEMENT MODEL//ADD HEALTH TIP MODELfunc t i on process ach ievement ( ) {$achievement = $th i s−>input−>post ( ’ achievement ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;$data [ ’ achievement ’ ] = $achievement ;$th i s−>db−>i n s e r t ( ’ shared achievements ’ , $data ) ;

}

e l s eecho ( ’ Se s s i on Timeout . ’ ) ;

}

//VIEW CREATED RECIPES MODELfunc t i on p r o c e s s v i ew c r e a t e d r e c i p e s ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

/∗ $th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes o , i n g r ed i e n t s i ’ ) ;$ th i s−>db−>where ( ’ o . u s e r id ’ , $u s e r i d ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = i . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

$th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;

220

Page 232: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$th i s−>db−>order by ( ’ own rec ipe id ’ , ’ desc ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}//EDIT CREATED RECIPEfunc t i on g e t c r e a t e d r e c i p e ( $own rec ipe id ) {

$th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ , r .∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes o , i n g r ed i e n t s i , r e c i p e image s r ’ ) ;$ th i s−>db−>where ( ’ o . own rec ipe id ’ , $own rec ipe id ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = i . own rec ipe id ’ ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = r . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;

// return $query−>row array ( ) ;r e turn $query−>r e s u l t ( ) ;

}

//UPDATE RECIPE MODELpub l i c func t i on update r e c ipe ( $own rec ipe id , $data , $data2 ) {

$th i s−>db−>where ( ’ own rec ipe id ’ , $own rec ipe id ) ;$ th i s−>db−>update ( ’ own rec ipes ’ , $data ) ;// $own rec ipe id = $th i s−>db−>i n s e r t i d ( ) ;

// th i s−>db−>update ( ’ i ng r ed i en t s ’ , $data2 ) ;f o r ( $ i = 0 ; $ i < count ( $data2 [ ’ food name ’ ] ) ; $ i++) {

$data3 = array (’ food name ’=>$data2 [ ’ food name ’ ] [ $ i ] ,’ food group ’=>$data2 [ ’ food group ’ ] [ $ i ] ,’ measure ’=>$data2 [ ’ measure ’ ] [ $ i ] ,’ s e r v i n g s i z e ’=>$data2 [ ’ s e r v i n g s i z e ’ ] [ $ i ] ,

) ;i f ( $data2 [ ’ i n g r ed i en t i d ’ ] [ $ i ] == nu l l | | $data2 [ ’ i n g r ed i en t i d ’ ] [ $ i ]

== ””) {$data3 [ ’ own rec ipe id ’ ] = $own rec ipe id ;$th i s−>db−>i n s e r t ( ’ i ng r ed i en t s ’ , $data3 ) ;

} e l s e {$th i s−>db−>where ( ’ i n g r ed i en t i d ’ , $data2 [ ’ i n g r ed i en t i d ’ ] [ $ i ] )

;$ th i s−>db−>update ( ’ i ng r ed i en t s ’ , $data3 ) ;

}}

}

//VIEW RECOMMENDED RECIPESfunc t i on process v iew recommended rec ipes ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

/∗ $th i s−>db−>s e l e c t ( ’ h ea l th cond i t i on ’ ) ;$ th i s−>db−>from ( ’ hea l th cond i t i on s ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$ th i s−>db−>order by (” r e co rd date ” , ” desc ”) ;$th i s−>db−>l im i t (1 ) ;$que ry hea l th cond i t i on = $th i s−>db−>get ( ) ;$que ry hea l th cond i t i on−>r e s u l t ( ) ;f o r each ( $que ry hea l th cond i t i on−>r e s u l t ( ) as $row ) {

$hea l th cond i t i on = $row−>hea l t h cond i t i on ;}∗/

$th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ recommended recipes ’ ) ;// $th i s−>db−>where ( ’ hea l th cond i t i on ’ , $hea l th cond i t i on ) ;$th i s−>db−>order by ( ’ recommended recipe id ’ , ’ desc ’ ) ;// $th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

//SEARCH RECOMMENDED RECIPESfunc t i on g e t s e a r c h r e c r e c ( ) {

$match = $th i s−>input−>post ( ’ s e a r ch r e c r e c ’ ) ;$ th i s−>db−>l i k e ( ’ recommended recipe id ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ h ea l th cond i t i on ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ meal type ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ recipe name ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ s e rv ing sugg ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ c a l o r i e s ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ carbohydrate ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ prote in ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ fat ’ , $match ) ;$th i s−>db−>order by ( ’ recommended recipe id ’ , ’ desc ’ ) ;

$query = $th i s−>db−>get ( ’ recommended recipes ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//VIEW SHARED RECIPESfunc t i on p r o c e s s v i ew sha r ed r e c i p e s ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

$th i s−>db−>s e l e c t ( ’ s .∗ , o .∗ ’ ) ;

221

Page 233: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$th i s−>db−>from ( ’ s h a r ed r e c i p e s s , own rec ipes o ’ ) ;$ th i s−>db−>where ( ’ s . own rec ipe id = o . own rec ipe id ’ ) ;$ th i s−>db−>order by ( ’ s h a r ed r e c i p e i d ’ , ’ desc ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

//SEARCH SHARED RECIPESfunc t i on g e t s e a r ch sha r ed r e c ( ) {

$match = $th i s−>input−>post ( ’ s ea r ch sharedrec ’ ) ;

$ th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ sha r ed r e c i p e s ’ ) ;$ th i s−>db−>j o i n ( ’ own rec ipes ’ , ’ s h a r ed r e c i p e s . own rec ipe id = own rec ipes .

own rec ipe id ’ ) ;

$ th i s−>db−>l i k e ( ’ s h a r ed r e c i p e i d ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ h ea l th cond i t i on ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ meal type ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ recipe name ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ s e rv ing sugg ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ c a l o r i e s ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ carbohydrate ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ prote in ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ fat ’ , $match ) ;$th i s−>db−>order by ( ’ s h a r ed r e c i p e i d ’ , ’ desc ’ ) ;

$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}

//VIEW DAILY MEALS BY DATE MODELpub l i c func t i on recommended show data by date ( $ r eco rd date ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;// $cond i t i on = ” reco rd date =” . ” ’” . $ r e co rd date . ” ’ ” ;

$ th i s−>db−>s e l e c t ( ’ h ea l th cond i t i on ’ ) ;$ th i s−>db−>from ( ’ hea l th cond i t i on s ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$ th i s−>db−>order by (” r e co rd date ” , ” desc ”) ;$th i s−>db−>l im i t (1 ) ;$que ry hea l th cond i t i on = $th i s−>db−>get ( ) ;$que ry hea l th cond i t i on−>r e s u l t ( ) ;f o r each ( $que ry hea l th cond i t i on−>r e s u l t ( ) as $row ) {

$hea l th cond i t i on = $row−>hea l t h cond i t i on ;}

$th i s−>db−>s e l e c t ( ’ d .∗ , r .∗ ’ ) ;$ th i s−>db−>from ( ’ recommended dai ly meals d , recommended recipes r ’ ) ;$ th i s−>db−>where ( ’ d . record date ’ , $ r e co rd date ) ;$ th i s−>db−>where ( ’ d . recommended rec ipe id = r . recommended recipe id ’ ) ;$ th i s−>db−>where ( ’ r . h ea l th cond i t i on ’ , $hea l th cond i t i on ) ;$th i s−>db−>order by ( ’ meal group ’ , ’ asc ’ ) ;

$query = $th i s−>db−>get ( ) ;

i f ( $query−>num rows ( ) > 0) {re turn $query−>r e s u l t ( ) ;

} e l s e {re turn f a l s e ;

}}

}

//VIEW RECIPEfunc t i on g e t r e c i p e c on t e n t s ( $own rec ipe id ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

/∗ $th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes o , i n g r ed i e n t s i ’ ) ;$ th i s−>db−>where ( ’ o . u s e r id ’ , $u s e r i d ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = i . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

/∗ $th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ i ng r ed i en t s ’ ) ;$ th i s−>db−>where (” own rec ipe id ” , $own rec ipe id ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

$th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ , r .∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes o , i n g r ed i e n t s i , r e c i p e image s r ’ ) ;$ th i s−>db−>where ( ’ i . own rec ipe id ’ , $own rec ipe id ) ;$ th i s−>db−>where ( ’ i . own rec ipe id = o . own rec ipe id ’ ) ;$ th i s−>db−>where ( ’ r . own rec ipe id = o . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

222

Page 234: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

//VIEW RECOMMENDED RECIPEfunc t i on get recommended rec ipe contents ( $recommended rec ipe id ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

/∗ $th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes o , i n g r ed i e n t s i ’ ) ;$ th i s−>db−>where ( ’ o . u s e r id ’ , $u s e r i d ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = i . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

/∗ $th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ i ng r ed i en t s ’ ) ;$ th i s−>db−>where (” own rec ipe id ” , $own rec ipe id ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

$th i s−>db−>s e l e c t ( ’ r .∗ , i .∗ , c .∗ ’ ) ;$ th i s−>db−>from ( ’ recommended recipes r , ingredients recommended i ,

recipe images recommended c ’ ) ;$ th i s−>db−>where ( ’ i . recommended recipe id ’ , $recommended rec ipe id ) ;$ th i s−>db−>where ( ’ i . recommended rec ipe id = r . recommended recipe id ’ ) ;$ th i s−>db−>where ( ’ c . recommended rec ipe id = r . recommended recipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

//VIEW SHARED RECIPEfunc t i on g e t s h a r e d r e c i p e c on t e n t s ( $ s h a r e d r e c i p e i d ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;$data [ ’ u s e r id ’ ] = $u s e r i d ;

/∗ $th i s−>db−>s e l e c t ( ’ o .∗ , i .∗ ’ ) ;$ th i s−>db−>from ( ’ own rec ipes o , i n g r ed i e n t s i ’ ) ;$ th i s−>db−>where ( ’ o . u s e r id ’ , $u s e r i d ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = i . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

/∗ $th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ i ng r ed i en t s ’ ) ;$ th i s−>db−>where (” own rec ipe id ” , $own rec ipe id ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;∗/

$th i s−>db−>s e l e c t ( ’ s .∗ , o .∗ , i .∗ , r .∗ ’ ) ;$ th i s−>db−>from ( ’ s h a r ed r e c i p e s s , own rec ipes o , i n g r ed i e n t s i ,

r e c i p e image s r ’ ) ;$ th i s−>db−>where ( ’ s . s h a r ed r e c i p e i d ’ , $ s h a r e d r e c i p e i d ) ;$ th i s−>db−>where ( ’ s . own rec ipe id = o . own rec ipe id ’ ) ;$ th i s−>db−>where ( ’ o . own rec ipe id = i . own rec ipe id ’ ) ;$ th i s−>db−>where ( ’ r . own rec ipe id = o . own rec ipe id ’ ) ;$query = $th i s−>db−>get ( ) ;r e turn $query−>r e s u l t ( ) ;

}}

//DELETE CREATED RECIPEpub l i c func t i on d e l c r e a t e d r e c i p e ( $own rec ipe id ) {

// $th 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 ) ;$ th i s−>db−>de l e t e ( ’ own rec ipes ’ , array ( ’ own rec ipe id ’ => $own rec ipe id ) ) ;$ th i s−>db−>de l e t e ( ’ i ng r ed i en t s ’ , array ( ’ own rec ipe id ’ => $own rec ipe id ) ) ;$ th i s−>db−>de l e t e ( ’ r ec ipe images ’ , array ( ’ own rec ipe id ’ => $own rec ipe id ) ) ;

}

//DELETE INGREDIENTSpub l i c func t i on d e l i n g r e d i e n t ( $ i n g r e d i e n t i d ) {

$th i s−>db−>de l e t e ( ’ i ng r ed i en t s ’ , array ( ’ i n g r ed i en t i d ’ => $ i n g r e d i e n t i d ) ) ;}

//SHARE CREATED RECIPEfunc t i on p r o c e s s s h a r e r e c i p e ( $own rec ipe id ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d = $ s e s s i on da t a [ ’ u s e r id ’ ] ;

$data [ ’ u s e r id ’ ] = $u s e r i d ;$data [ ’ own rec ipe id ’ ] = $own rec ipe id ;

$th i s−>db−>i n s e r t ( ’ s ha r ed r e c i p e s ’ , $data ) ;}e l s e

echo ” Ses s i on Timeout ” ;}

//ADD RECIPE MODELfunc t i on p ro c e s s add r e c i p e ( $data3 ){// $hea l th cond i t i on = $th i s−>input−>post ( ’ h ea l th cond i t i on ’ ) ;$h ea l th cond i t i on = implode (” ,” , $th i s−>input−>post ( ’ h ea l th cond i t i on ’ ) ) ;$meal type = $th i s−>input−>post ( ’ meal type ’ ) ;$rec ipe name = $th i s−>input−>post ( ’ recipe name ’ ) ;$ s e rv ing sugg = $th i s−>input−>post ( ’ s e rv ing sugg ’ ) ;$preparat i on procedure = $th i s−>input−>post ( ’ preparat ion procedure ’ ) ;

223

Page 235: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ c a l o r i e s = $th i s−>input−>post ( ’ c a l o r i e s ’ ) ;$carbohydrate = $th i s−>input−>post ( ’ carbohydrate ’ ) ;$pro te in = $th i s−>input−>post ( ’ prote in ’ ) ;$ f a t = $th i s−>input−>post ( ’ fat ’ ) ;

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;

$data [ ’ u s e r id ’ ] = $u s e r i d ;$data [ ’ h ea l th cond i t i on ’ ] = $hea l th cond i t i on ;$data [ ’ meal type ’ ] = $meal type ;$data [ ’ recipe name ’ ] = $rec ipe name ;$data [ ’ s e rv ing sugg ’ ]= $se rv ing sugg ;$data [ ’ preparat ion procedure ’ ] = $preparat i on procedure ;$data [ ’ c a l o r i e s ’ ] = $ c a l o r i e s ;$data [ ’ carbohydrate ’ ] = $carbohydrate ;$data [ ’ prote in ’ ] = $prote in ;$data [ ’ fat ’ ] = $ f a t ;

$ th i s−>db−>i n s e r t ( ’ own rec ipes ’ , $data ) ;

$own rec ipe id = $th i s−>db−>i n s e r t i d ( ) ;

i f ( i s s e t ($ POST [ ’ i ng r ed i en t s ’ ] , $ POST [ ’ food group ’ ] , $ POST [ ’ingred ient measure ’ ] , $ POST [ ’ i ng r ed i en t quant i t y ’ ] ) ){

f o r ( $ i =0; $i<count ($ POST [ ’ i ng r ed i en t s ’ ] ) ; $ i++) {$ i ng r ed i en t s = $ POST [ ’ i ng r ed i en t s ’ ] [ $ i ] ;$ food group = $ POST [ ’ food group ’ ] [ $ i ] ;$ ingred i ent measure =$ POST [ ’ ingred ient measure ’ ] [ $ i ] ;$ i n g r ed i en t quan t i t y = $ POST [ ’ i ng r ed i en t quant i t y ’ ] [

$ i ] ;$data2 [ ’ own rec ipe id ’ ] = $own rec ipe id ;$data2 [ ’ food name ’ ] = $ i ng r ed i en t s ;$data2 [ ’ food group ’ ] = $food group ;$data2 [ ’ measure ’ ] = $ ingred i ent measure ;$data2 [ ’ s e r v i n g s i z e ’ ] = $ ing r ed i en t quan t i t y ;/∗$counts = ar ray count va lue s ( $food group ) ;echo $counts [ ’ Vegetable ’ ] ;∗/$th i s−>db−>i n s e r t ( ’ i ng r ed i en t s ’ , $data2 ) ;

}}

/∗ $ f i l e=array (’ img name’=>$data [ ’ raw name ’ ] ,’ thumb name’=>$data [ ’ raw name ’ ] . ’ thumb ’ ,’ ext ’=>$data [ ’ f i l e e x t ’ ] ,’ upload date ’=>time ( )

) ;∗//∗ $data3 [ ’ raw name ’ ] ;$data3 [ ’ raw name ’ ] . ’ thumb ’ ;$data3 [ ’ f i l e e x t ’ ] ;$data3 [ ’ upload date ’ ] = time ( ) ;∗/$data3 [ ’ own rec ipe id ’ ] = $own rec ipe id ;

$th i s−>db−>i n s e r t ( ’ r ec ipe images ’ , $data3 ) ;

}

e l s eecho ” Ses s i on Timeout ” ;

}

//ADD INGREDIENT AUTOCOMPLETE//USER SEARCH MODEL/S

func t i on GetAutocomplete ( $opt ions = array ( ) ) {$th i s−>db−>s e l e c t ( ’ food group , food name , we i gh t ed ib l e po r t i on , energy ,

carbohydrate , prote in , fat ’ ) ;$ th i s−>db−>l i k e ( ’ food name ’ , $opt ions [ ’ keyword ’ ] , ’ a f t e r ’ ) ;

$query = $th i s−>db−>get ( ’ f o od ex change l i s t ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//SEARCH FOR MEAL MODELfunc t i on ge t s ea r ch mea l ( ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d = $ s e s s i on da t a [ ’ u s e r id ’ ] ;

}e l s e

echo ” Ses s i on Timeout ” ;

/∗ $th i s−>db−>s e l e c t ( ’ h ea l th cond i t i on ’ ) ;$ th i s−>db−>from ( ’ hea l th cond i t i on s ’ ) ;$ th i s−>db−>where (” u s e r i d ” , $u s e r i d ) ;$ th i s−>db−>order by (” r e co rd date ” , ” desc ”) ;$th i s−>db−>l im i t (1 ) ;$que ry hea l th cond i t i on = $th i s−>db−>get ( ) ;$que ry hea l th cond i t i on−>r e s u l t ( ) ;f o r each ( $que ry hea l th cond i t i on−>r e s u l t ( ) as $row ) {

$hea l th cond i t i on = $row−>hea l t h cond i t i on ;}∗/

$match = $th i s−>input−>post ( ’ search meal ’ ) ;/∗ $query = ”( own rec ipe id LIKE ’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match ) .”% ’ OR

us e r i d LIKE ’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match ) .”% ’ OR meal type LIKE’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match )

224

Page 236: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

.”% ’ OR recipe name LIKE ’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match ) .”% ’ ORse rv ing sugg LIKE ’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match ) .”% ’ ORprepara t i on procedure LIKE ’%”. $th 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 ’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match ) .”% ’ ORcarbohydrate LIKE ’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match ) .”% ’ OR prot e inLIKE ’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match )

.”% ’ OR fa t LIKE ’%”. $th i s−>db−>e s c a p e l i k e s t r ( $match ) .”% ’) ANDhea l th cond i t i on = ”;∗/

$th i s−>db−>l i k e ( ’ own rec ipe id ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ u s e r id ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ meal type ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ recipe name ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ s e rv ing sugg ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ preparat ion procedure ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ c a l o r i e s ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ carbohydrate ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ prote in ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ fat ’ , $match ) ;$th i s−>db−>o r l i k e ( ’ h ea l th cond i t i on ’ , $match ) ;// $th i s−>db−>where ( $query , $hea l th cond i t i on ) ;$th i s−>db−>order by ( ’ own rec ipe id ’ , ’ desc ’ ) ;$ th i s−>db−>where ( ’ u s e r id ’ , $ u s e r i d ) ;$query = $th i s−>db−>get ( ’ own rec ipes ’ ) ;r e turn $query−>r e s u l t ( ) ;

}

//ADD MEALfunc t i on process addmeal ( $own rec ipe id ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {

$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d = $ s e s s i on da t a [ ’ u s e r id ’ ] ;$meal group = $th i s−>input−>post ( ’ meal group ’ ) ;$ r e co rd date = $th i s−>input−>post ( ’ r ecord date ’ ) ;

$data [ ’ u s e r id ’ ] = $u s e r i d ;$data [ ’ own rec ipe id ’ ] = $own rec ipe id ;$data [ ’ meal group ’ ] = $meal group ;$data [ ’ r ecord date ’ ] = $reco rd date ;

$th i s−>db−>i n s e r t ( ’ p l an da i l y mea l s ’ , $data ) ;}e l s e

echo ” Ses s i on Timeout ” ;}

//DELETE MEALpub l i c func t i on de l mea l ( $p l an da i l y mea l i d ) {

// $th 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 ) ;$ th i s−>db−>de l e t e ( ’ p l an da i l y mea l s ’ , array ( ’ p l an da i l y mea l i d ’ =>

$p l an da i l y mea l i d ) ) ;}

//VIEW DAILY MEALS BY DATE MODELpub l i c func t i on show data by date ( $ r eco rd date ) {

i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;// $data [ ’ u s e r id ’ ] = $u s e r i d ;// $cond i t i on = ” reco rd date =” . ” ’” . $ r e co rd date . ” ’ ” ;

$ th i s−>db−>s e l e c t ( ’ p .∗ , o .∗ ’ ) ;$ th i s−>db−>from ( ’ p l an da i l y mea l s p , own rec ipes o ’ ) ;$ th i s−>db−>where (”p . u s e r i d ” , $u s e r i d ) ;$ th i s−>db−>where ( ’ p . record date ’ , $ r e co rd date ) ;$ th i s−>db−>where ( ’ p . own rec ipe id = o . own rec ipe id ’ ) ;$ th i s−>db−>order by ( ’ meal group ’ , ’ asc ’ ) ;

$query1 = $th i s−>db−>get ( ) ;

$ th i s−>db−>s e l e c t ( ’ f .∗ , h .∗ ’ ) ;$ th 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 ond i t i o n s h ’ ) ;$ th i s−>db−>where ( ’ f . u s e r id ’ , $ u s e r i d ) ;$ th 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 ’ ) ;// $th i s−>db−>where ( ’ f . r e co rd date = h . record date ’ ) ;$ th i s−>db−>order by (” f . r e co rd date ” , ” desc ”) ;

$th i s−>db−>l im i t (1 ) ;$query2 = $th i s−>db−>get ( ) ;

$ r e s u l t 1 = $query1−>r e s u l t ( ) ;$ r e s u l t 2 = $query2−>r e s u l t ( ) ;

i f ( $query1−>num rows ( ) > 0 && $query2−>num rows ( ) > 0) {re turn array merge ( $ r e su l t1 , $ r e s u l t 2 ) ;

} e l s e {re turn f a l s e ;

}

/∗ i f ( $query−>num rows ( ) > 0) {re turn $query−>r e s u l t ( ) ;

} e l s e {re turn f a l s e ;

}∗/}

}

pub l i c func t i on s h ow c a l o r i e l im i t ( ) {i f ( $ th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ) {$ s e s s i on da t a = $th i s−>s e s s i on−>userdata ( ’ l ogged in ’ ) ;$u s e r i d= $ s e s s i on da t a [ ’ u s e r id ’ ] ;

225

Page 237: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$data [ ’ u s e r id ’ ] = $u s e r i d ;

$th i s−>db−>s e l e c t ( ’∗ ’ ) ;$ th i s−>db−>from ( ’ f i t n e s s p r o f i l e ’ ) ;$ th i s−>db−>where ( ’ u s e r id ’ , $ u s e r i d ) ;$ th i s−>db−>order by (” r e co rd date ” , ” desc ”) ;

$th i s−>db−>l im i t (1 ) ;$query = $th i s−>db−>get ( ) ;i f ( $query−>num rows ( ) > 0) {

re turn $query−>r e s u l t ( ) ;} e l s e {

re turn f a l s e ;}

}}

}

?>

<?php

Class Login Model extends CI Model {f unc t i on l o g i n ( $username , $password ) {

$query = $ th i s −> db −> get where ( ’ users ’ , array ( ’ username ’=>$username , ’password ’=>MD5( $password ) ) ) ;

i f ( $query −> num rows ( ) == 1) {re turn $query−>r e s u l t ( ) ;

}

e l s e {re turn f a l s e ;

}}

f unc t i on proce s s ( ) {$username = $th i s−>input−>post ( ’ username reg ’ ) ;

$password = $th i s−>input−>post ( ’ password reg ’ ) ;$conf i rm password = $th i s−>input−>post ( ’

conf i rm password reg ’ ) ;$ f i r s t name = $th i s−>input−>post ( ’ f i r s t name ’ ) ;$middle name = $th i s−>input−>post ( ’ middle name ’ ) ;$ last name = $th i s−>input−>post ( ’ last name ’ ) ;$gender = $th i s−>input−>post ( ’ genderRadio ’ ) ;$use r type = $th i s−>input−>post ( ’ userTypeRadio ’ ) ;$ ema i l addre s s = $th i s−>input−>post ( ’ emai l address ’ ) ;$birthday = $th i s−>input−>post ( ’ b i r thdate ’ ) ;

$data = array (’ username ’ => $username ,

’ password ’ => MD5( $password ) ,’ conf irm password ’ => MD5( $conf irm password ) ,’ f i r s t name ’ => $ f i r s t name ,’ middle name ’ => $middle name ,’ last name ’ => $last name ,’ gender ’ => $gender ,’ user type ’ => $user type ,’ emai l address ’ => $emai l address ,’ birthday ’ => $birthday

) ;$th i s−>db−>i n s e r t ( ’ users ’ , $data ) ;

}

pub l i c func t i on c h e c k u s e r e x i s t ( $usr ) {$th i s−>db−>where (” username ” , $usr ) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}

pub l i c func t i on ch e ck ema i l e x i s t ( $eml ) {$th i s−>db−>where (” ema i l addre s s ” , $eml ) ;$query=$th i s−>db−>get (” use r s ”) ;i f ( $query−>num rows ( )>0) {

re turn true ;}e l s e {

re turn f a l s e ;}

}}

?>

B..4 Libraries

<?php/∗∗∗ Copyright 2011 Facebook , Inc .∗∗ Licensed under the Apache License , Vers ion 2 .0 ( the ” License ”) ; you may∗ not use t h i s f i l e except in compliance with the L icense . You may obta in∗ a copy o f the L icense at

226

Page 238: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗∗ http ://www. apache . org / l i c e n s e s /LICENSE−2.0∗∗ Unless r equ i r ed by app l i c ab l e law or agreed to in wr i t ing , so f tware∗ d i s t r i bu t ed under the L icense i s d i s t r i bu t ed on an ”AS IS” BASIS , WITHOUT∗ WARRANTIES OR CONDITIONS OF ANY KIND, e i t h e r expre s s or impl i ed . See the∗ License f o r the s p e c i f i c language governing permi s s i ons and l im i t a t i o n s∗ under the L icense .∗/

i f ( ! f u n c t i o n e x i s t s ( ’ c u r l i n i t ’ ) ) {throw new Exception ( ’ Facebook needs the CURL PHP extens ion . ’ ) ;

}i f ( ! f u n c t i o n e x i s t s ( ’ j son decode ’ ) ) {

throw new Exception ( ’ Facebook needs the JSON PHP extens ion . ’ ) ;}

/∗∗∗ Thrown when an API c a l l r e tu rns an except ion .∗∗ @author Nai t ik Shah <nait ik@facebook . com>∗/

c l a s s FacebookApiException extends Exception{

/∗∗∗ The r e s u l t from the API s e r v e r that r ep r e s en t s the except ion in format ion .∗∗ @var mixed∗/

protec ted $ r e s u l t ;

/∗∗∗ Make a new API Exception with the given r e s u l t .∗∗ @param array $ r e s u l t The r e s u l t from the API s e r v e r∗/

pub l i c func t i on c on s t r u c t ( $ r e s u l t ) {$th 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 ro r code ’ ] ) && i s i n t ( $ r e s u l t [ ’ e r ro r code ’ ] ) ) {

$code = $ r e s u l t [ ’ e r ro r code ’ ] ;}

i f ( i s s e t ( $ r e s u l t [ ’ e r r o r d e s c r i p t i o n ’ ] ) ) {// OAuth 2 .0 Draft 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 ror ’ ] ) && i s a r r a y ( $ r e s u l t [ ’ e r ror ’ ] ) ) {// OAuth 2 .0 Draft 00 s t y l e$msg = $ r e s u l t [ ’ e r ror ’ ] [ ’ message ’ ] ;

} e l s e i f ( i s s e t ( $ r e s u l t [ ’ error msg ’ ] ) ) {// Rest s e r v e r s t y l e$msg = $ r e s u l t [ ’ error msg ’ ] ;

} e l s e {$msg = ’Unknown Error . Check getResu l t ( ) ’ ;

}

parent : : c o n s t r u c t ($msg , $code ) ;}

/∗∗∗ Return the a s s o c i a t ed r e s u l t ob j e c t returned by the API s e rv e r .∗∗ @return array The r e s u l t from the API s e r v e r∗/

pub l i c func t i on getResu l t ( ) {re turn $th i s−>r e s u l t ;

}

/∗∗∗ Returns the a s s o c i a t ed type f o r the e r r o r . This w i l l d e f au l t to∗ ’ Exception ’ when a type i s not a v a i l a b l e .∗∗ @return s t r i n g∗/

pub l i c func t i on getType ( ) {i f ( i s s e t ( $th i s−>r e s u l t [ ’ e r ror ’ ] ) ) {

$e r r o r = $th i s−>r e s u l t [ ’ e r ror ’ ] ;i f ( i s s t r i n g ( $ e r r o r ) ) {

// OAuth 2 .0 Draft 10 s t y l ere turn $e r r o r ;

} e l s e i f ( i s a r r a y ( $ e r r o r ) ) {// OAuth 2 .0 Draft 00 s t y l ei f ( i s s e t ( $ e r r o r [ ’ type ’ ] ) ) {

re turn $e r r o r [ ’ type ’ ] ;}

}}

re turn ’ Exception ’ ;}

/∗∗∗ To make debugging e a s i e r .∗∗ @return s t r i n g The s t r i n g r ep r e s en t a t i on o f the e r r o r∗/

pub l i c func t i on t o S t r i n g ( ) {$ s t r = $th i s−>getType ( ) . ’ : ’ ;

227

Page 239: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

i f ( $ th i s−>code != 0) {$ s t r .= $th i s−>code . ’ : ’ ;

}re turn $ s t r . $ th i s−>message ;

}}

/∗∗∗ Provides a c c e s s to the Facebook Platform . This c l a s s prov ides∗ a major i ty o f the f u n c t i o n a l i t y needed , but the c l a s s i s ab s t ra c t∗ because i t i s des igned to be sub−c l a s s ed . The subc l a s s must∗ implement the four abs t ra c t methods l i s t e d at the bottom of∗ the f i l e .∗∗ @author Nai t ik Shah <nait ik@facebook . com>∗/

abs t rac t c l a s s BaseFacebook{

/∗∗∗ Vers ion .∗/

const VERSION = ’ 3 . 2 . 3 ’ ;

/∗∗∗ Signed Request Algorithm .∗/

const SIGNED REQUEST ALGORITHM = ’HMAC−SHA256 ’ ;

/∗∗∗ Defaul t opt ions f o r cu r l .∗∗ @var array∗/

pub l i c s t a t i c $CURL OPTS = array (CURLOPTCONNECTTIMEOUT => 10 ,CURLOPTRETURNTRANSFER => true ,CURLOPT TIMEOUT => 60 ,CURLOPT USERAGENT => ’ facebook−php−3.2 ’ ,

) ;

/∗∗∗ L i s t o f query parameters that get automat i ca l l y dropped when r ebu i l d i ng∗ the cur rent URL.∗∗ @var array∗/

protec ted s t a t i c $DROP QUERY PARAMS = array (’ code ’ ,’ s tate ’ ,’ s i gned reque s t ’ ,

) ;

/∗∗∗ Maps a l i a s e s to Facebook domains .∗∗ @var array∗/

pub l i c s t a t i c $DOMAIN MAP = array (’ api ’ => ’ https :// api . facebook . com/ ’ ,’ ap i v ideo ’ => ’ https :// api−video . facebook . com/ ’ ,’ ap i read ’ => ’ https :// api−read . facebook . com/ ’ ,’ graph ’ => ’ https :// graph . facebook . com/ ’ ,’ graph video ’ => ’ https :// graph−video . facebook . com/ ’ ,’www’ => ’ https ://www. facebook . com/ ’ ,

) ;

/∗∗∗ The Appl i cat ion ID .∗∗ @var s t r i n g∗/

protec ted $appId ;

/∗∗∗ The Appl i cat ion App Sec re t .∗∗ @var s t r i n g∗/

protec ted $appSecret ;

/∗∗∗ The ID of the Facebook user , or 0 i f the user i s logged out .∗∗ @var i n t e g e r∗/

protec ted $user ;

/∗∗∗ The data from the s i gn ed r eque s t token .∗∗ @var s t r i n g∗/

protec ted $s ignedRequest ;

/∗∗∗ A CSRF s t a t e va r i ab l e to a s s i s t in the de f ense aga in s t CSRF attacks .∗∗ @var s t r i n g∗/

228

Page 240: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

protec ted $ s ta t e ;

/∗∗∗ The OAuth acc e s s token r e c e i v ed in exchange f o r a va l i d au tho r i z a t i on∗ code . nu l l means the ac c e s s token has yet to be determined .∗∗ @var s t r i n g∗/

protec ted $accessToken = nu l l ;

/∗∗∗ I nd i c a t e s i f the CURL based @ syntax f o r f i l e uploads i s enabled .∗∗ @var boolean∗/

protec ted $ f i l eUploadSupport = f a l s e ;

/∗∗∗ I nd i c a t e s i f we t ru s t HTTP X FORWARDED ∗ headers .∗∗ @var boolean∗/

protec ted $trustForwarded = f a l s e ;

/∗∗∗ I nd i c a t e s i f s i gn ed r eque s t i s a l lowed in query parameters .∗∗ @var boolean∗/

protec ted $al lowSignedRequest = true ;

/∗∗∗ I n i t i a l i z e a Facebook Appl i cat ion .∗∗ The con f i gu r a t i on :∗ − appId : the app l i c a t i on ID∗ − s e c r e t : the app l i c a t i on s e c r e t∗ − f i l eUp l oad : ( op t i ona l ) boolean i nd i c a t i n g i f f i l e uploads are enabled∗ − al lowSignedRequest : ( op t i ona l ) boolean i nd i c a t i n g i f s i gn ed r eque s t i s∗ al lowed in query parameters or POST body . Should be∗ f a l s e f o r non−canvas apps . De fau l t s to true .∗∗ @param array $con f i g The app l i c a t i on con f i gu r a t i on∗/

pub l i c func t i on c on s t r u c t ( $ con f i g ) {$th i s−>setAppId ( $con f i g [ ’ appId ’ ] ) ;$ th i s−>setAppSecret ( $ con f i g [ ’ s e c r e t ’ ] ) ;i f ( i s s e t ( $ con f i g [ ’ f i l eUp load ’ ] ) ) {

$th i s−>setFi leUploadSupport ( $ con f i g [ ’ f i l eUp load ’ ] ) ;}i f ( i s s e t ( $ con f i g [ ’ trustForwarded ’ ] ) && $con f i g [ ’ trustForwarded ’ ] ) {

$th i s−>trustForwarded = true ;}i f ( i s s e t ( $ con f i g [ ’ a l lowSignedRequest ’ ] )

&& ! $con f i g [ ’ a l lowSignedRequest ’ ] ) {$th i s−>al lowSignedRequest = f a l s e ;

}$ s t a t e = $th i s−>getPer s i s t entData ( ’ s tate ’ ) ;i f ( ! empty ( $ s t a t e ) ) {

$th i s−>s t a t e = $s ta t e ;}

}

/∗∗∗ Set the Appl i cat ion ID .∗∗ @param s t r i n g $appId The Appl i cat ion ID∗∗ @return BaseFacebook∗/

pub l i c func t i on setAppId ( $appId ) {$th i s−>appId = $appId ;re turn $ th i s ;

}

/∗∗∗ Get the Appl i cat ion ID .∗∗ @return s t r i n g the Appl i cat ion ID∗/

pub l i c func t i on getAppId ( ) {re turn $th i s−>appId ;

}

/∗∗∗ Set the App Sec re t .∗∗ @param s t r i n g $ap iSec r e t The App Sec re t∗∗ @return BaseFacebook∗ @deprecated Use setAppSecret in s t ead .∗ @see setAppSecret ( )∗/

pub l i c func t i on se tAp iSec re t ( $ap iSec r e t ) {$th i s−>setAppSecret ( $ap iSec r e t ) ;r e turn $ th i s ;

}

/∗∗

229

Page 241: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗ Set the App Sec re t .∗∗ @param s t r i n g $appSecret The App Sec re t∗∗ @return BaseFacebook∗/

pub l i c func t i on setAppSecret ( $appSecret ) {$th i s−>appSecret = $appSecret ;r e turn $ th i s ;

}

/∗∗∗ Get the App Sec re t .∗∗ @return s t r i n g the App Sec re t∗∗ @deprecated Use getAppSecret in s t ead .∗ @see getAppSecret ( )∗/

pub l i c func t i on getApiSecret ( ) {re turn $th i s−>getAppSecret ( ) ;

}

/∗∗∗ Get the App Sec re t .∗∗ @return s t r i n g the App Sec re t∗/

pub l i c func t i on getAppSecret ( ) {re turn $th i s−>appSecret ;

}

/∗∗∗ Set the f i l e upload support s t a tu s .∗∗ @param boolean $f i l eUploadSupport The f i l e upload support s t a tu s .∗∗ @return BaseFacebook∗/

pub l i c func t i on setFi leUploadSupport ( $ f i l eUploadSupport ) {$th i s−>f i l eUploadSupport = $f i l eUploadSupport ;r e turn $ th i s ;

}

/∗∗∗ Get the f i l e upload support s t a tu s .∗∗ @return boolean true i f and only i f the s e r v e r supports f i l e upload .∗/

pub l i c func t i on getFi leUploadSupport ( ) {re turn $th i s−>f i l eUploadSupport ;

}

/∗∗∗ Get the f i l e upload support s t a tu s .∗∗ @return boolean true i f and only i f the s e r v e r supports f i l e upload .∗∗ @deprecated Use getFi leUploadSupport in s t ead .∗ @see getFi leUploadSupport ( )∗/

pub l i c func t i on useFi leUploadSupport ( ) {re turn $th i s−>getFi leUploadSupport ( ) ;

}

/∗∗∗ Sets the acc e s s token f o r api c a l l s . Use t h i s i f you get∗ your ac c e s s token by other means and j u s t want the SDK∗ to use i t .∗∗ @param s t r i n g $acce s s token an acc e s s token .∗∗ @return BaseFacebook∗/

pub l i c func t i on setAccessToken ( $acce s s token ) {$th i s−>accessToken = $acce s s token ;re turn $ th i s ;

}

/∗∗∗ Extend an acc e s s token , whi le removing the short−l i v e d token that might∗ have been generated v ia c l i e n t−s i d e f low . Thanks to http :// b i t . l y /b0Pt0H∗ f o r the workaround .∗/

pub l i c func t i on setExtendedAccessToken ( ) {t ry {

// need to circumvent j son decode by c a l l i n g oauthRequest// d i r e c t l y , s i n c e response isn ’ t JSON format .$a c c e s s t ok en r e spon s e = $th i s−> oauthRequest (

$th i s−>getUr l ( ’ graph ’ , ’/ oauth/ acces s token ’ ) ,$params = array (

’ c l i e n t i d ’ => $th i s−>getAppId ( ) ,’ c l i e n t s e c r e t ’ => $th i s−>getAppSecret ( ) ,’ grant type ’ => ’ fb exchange token ’ ,’ fb exchange token ’ => $th i s−>getAccessToken ( ) ,

)) ;

}catch ( FacebookApiException $e ) {

230

Page 242: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

// most l i k e l y that user very r e c en t l y revoked autho r i z a t i on .// In any event , we don ’ t have an acc e s s token , so say so .re turn f a l s e ;

}

i f ( empty ( $ac c e s s t ok en r e spon s e ) ) {re turn f a l s e ;

}

$response params = array ( ) ;p a r s e s t r ( $acce s s token re sponse , $response params ) ;

i f ( ! i s s e t ( $response params [ ’ acce s s token ’ ] ) ) {re turn f a l s e ;

}

$th i s−>de s t r oySe s s i on ( ) ;

$ th i s−>s e tPe r s i s t en tData (’ acce s s token ’ , $response params [ ’ acce s s token ’ ]

) ;}

/∗∗∗ Determines the ac c e s s token that should be used f o r API c a l l s .∗ The f i r s t time t h i s i s ca l l ed , $th i s−>accessToken i s s e t equal∗ to e i t h e r a va l i d user a c c e s s token , or i t ’ s s e t to the app l i c a t i on∗ acc e s s token i f a va l i d user a c c e s s token wasn ’ t a v a i l a b l e . Subsequent∗ c a l l s re turn whatever the f i r s t c a l l returned .∗∗ @return s t r i n g The acc e s s token∗/

pub l i c func t i on getAccessToken ( ) {i f ( $ th i s−>accessToken !== nu l l ) {

// we ’ ve done t h i s a l ready and cached i t . Just re turn .re turn $th i s−>accessToken ;

}

// f i r s t e s t a b l i s h ac c e s s token to be the app l i c a t i on// acc e s s token , in case we navigate to the /oauth/ acc e s s t oken// endpoint , where SOME acce s s token i s r equ i r ed .$th i s−>setAccessToken ( $th i s−>getAppl icat ionAccessToken ( ) ) ;$u s e r a c c e s s t ok en = $th i s−>getUserAccessToken ( ) ;i f ( $u s e r a c c e s s t ok en ) {

$th i s−>setAccessToken ( $u s e r a c c e s s t ok en ) ;}

re turn $th i s−>accessToken ;}

/∗∗∗ Determines and re tu rns the user a c c e s s token , f i r s t us ing∗ the s igned reques t i f present , and then f a l l i n g back on∗ the au tho r i z a t i on code i f p re sent . The in t en t i s to∗ re turn a va l i d user a c c e s s token , or f a l s e i f one i s determined∗ to not be av a i l a b l e .∗∗ @return s t r i n g A va l i d user a c c e s s token , or f a l s e i f one∗ could not be determined .∗/

protec ted func t i on getUserAccessToken ( ) {// f i r s t , c on s ide r a s igned reques t i f i t ’ s supp l i ed .// i f the re i s a s igned request , then i t a lone determines// the ac c e s s token .$ s i gned r eque s t = $th i s−>getSignedRequest ( ) ;i f ( $ s i gn ed r eque s t ) {

// apps . facebook . com hands the ac c e s s t oken in the s i gn ed r eque s ti f ( a r r a y k e y e x i s t s ( ’ oauth token ’ , $ s i gned r eque s t ) ) {

$acce s s token = $s i gned r eque s t [ ’ oauth token ’ ] ;$ th i s−>s e tPe r s i s t en tData ( ’ acce s s token ’ , $acc e s s token ) ;re turn $acce s s token ;

}

// the JS SDK puts a code in with the 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 gned r eque s t ) ) {

$code = $s i gned r eque s t [ ’ code ’ ] ;i f ( $code && $code == $th i s−>getPer s i s t entData ( ’ code ’ ) ) {

// short−c i r c u i t i f the code we have i s the same as the one presentedreturn $th i s−>getPer s i s t entData ( ’ acce s s token ’ ) ;

}

$acce s s token = $th i s−>getAccessTokenFromCode ( $code , ’ ’ ) ;i f ( $acce s s token ) {

$th i s−>s e tPe r s i s t en tData ( ’ code ’ , $code ) ;$th i s−>s e tPe r s i s t en tData ( ’ acce s s token ’ , $acc e s s token ) ;re turn $acce s s token ;

}}

// s igned reques t s t a t e s there ’ s no ac c e s s token , so anything// s to red should be c l e a r ed .$th i s−>c l e a rA l lPe r s i s t en tDa ta ( ) ;r e turn f a l s e ; // r e spe c t the s igned request ’ s data , even

// i f there ’ s an au tho r i z a t i on code or something e l s e}

$code = $th i s−>getCode ( ) ;i f ( $code && $code != $th i s−>getPer s i s t entData ( ’ code ’ ) ) {

$acce s s token = $th i s−>getAccessTokenFromCode ( $code ) ;

231

Page 243: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

i f ( $acce s s token ) {$th i s−>s e tPe r s i s t en tData ( ’ code ’ , $code ) ;$th i s−>s e tPe r s i s t en tData ( ’ acce s s token ’ , $acc e s s token ) ;re turn $acce s s token ;

}

// code was bogus , so everyth ing based on i t should be i nva l i d a t ed .$th i s−>c l e a rA l lPe r s i s t en tDa ta ( ) ;r e turn f a l s e ;

}

// as a f a l l ba ck , j u s t re turn whatever i s in the p e r s i s t e n t// store , knowing nothing e x p l i c i t ( s igned request , au tho r i z a t i on// code , e tc . ) was present to shadow i t ( or we saw a code in $ REQUEST,// but i t ’ s the same as what ’ s in the p e r s i s t e n t s t o r e )re turn $th i s−>getPer s i s t entData ( ’ acce s s token ’ ) ;

}

/∗∗∗ Retr i eve the s igned request , e i t h e r from a reques t parameter or ,∗ i f not present , from a cook i e .∗∗ @return s t r i n g the s igned request , i f ava i l ab l e , or nu l l o therwi se .∗/

pub l i c func t i on getSignedRequest ( ) {i f ( ! $ th i s−>s ignedRequest ) {

i f ( $ th i s−>al lowSignedRequest && ! empty ($ REQUEST[ ’ s i gned reque s t ’ ] ) ) {$th i s−>s ignedRequest = $th i s−>parseSignedRequest (

$ REQUEST[ ’ s i gned reque s t ’ ]) ;

} e l s e i f ( ! empty ($ COOKIE [ $th i s−>getSignedRequestCookieName ( ) ] ) ) {$th i s−>s ignedRequest = $th i s−>parseSignedRequest (

$ COOKIE [ $th i s−>getSignedRequestCookieName ( ) ] ) ;}

}re turn $th i s−>s ignedRequest ;

}

/∗∗∗ Get the UID of the connected user , or 0∗ i f the Facebook user i s not connected .∗∗ @return s t r i n g the UID i f a v a i l a b l e .∗/

pub l i c func t i on getUser ( ) {i f ( $ th i s−>user !== nu l l ) {

// we ’ ve a l ready determined t h i s and cached the value .re turn $th i s−>user ;

}

re turn $th i s−>user = $th i s−>getUserFromAvailableData ( ) ;}

/∗∗∗ Determines the connected user by f i r s t examining any s igned∗ request s , then con s i d e r i ng an autho r i z a t i on code , and then∗ f a l l i n g back to any p e r s i s t e n t s t o r e s t o r i n g the user .∗∗ @return i n t e g e r The id o f the connected Facebook user ,∗ or 0 i f no such user e x i s t s .∗/

protec ted func t i on getUserFromAvailableData ( ) {// i f a s igned reques t i s suppl ied , then i t s o l e l y determines// who the user i s .$ s i gned r eque s t = $th i s−>getSignedRequest ( ) ;i f ( $ s i gn ed r eque s t ) {

i f ( a r r a y k e y e x i s t s ( ’ u s e r id ’ , $ s i gned r eque s t ) ) {$user = $s i gned r eque s t [ ’ u s e r id ’ ] ;

i f ( $user != $th i s−>getPer s i s t entData ( ’ u s e r id ’ ) ){$th i s−>c l e a rA l lPe r s i s t en tDa ta ( ) ;

}

$th i s−>s e tPe r s i s t en tData ( ’ u s e r id ’ , $ s i gned r eque s t [ ’ u s e r id ’ ] ) ;r e turn $user ;

}

// i f the s igned reques t didn ’ t pre sent a user id , then i n v a l i d a t e// a l l e n t r i e s in any p e r s i s t e n t s t o r e .$th i s−>c l e a rA l lPe r s i s t en tDa ta ( ) ;r e turn 0 ;

}

$user = $th i s−>getPer s i s t entData ( ’ u s e r id ’ , $de f au l t = 0) ;$ p e r s i s t e d a c c e s s t o k en = $th i s−>getPer s i s t entData ( ’ acce s s token ’ ) ;

// use ac c e s s t oken to f e t ch user id i f we have a user acces s token , or i f// the cached acc e s s token has changed .$acce s s token = $th i s−>getAccessToken ( ) ;i f ( $acce s s token &&

$acce s s token != $th i s−>getAppl icat ionAccessToken ( ) &&! ( $user && $pe r s i s t e d a c c e s s t o k en == $acce s s token ) ) {

$user = $th i s−>getUserFromAccessToken ( ) ;i f ( $user ) {

$th i s−>s e tPe r s i s t en tData ( ’ u s e r id ’ , $user ) ;} e l s e {

$th i s−>c l e a rA l lPe r s i s t en tDa ta ( ) ;}

}

232

Page 244: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

re turn $user ;}

/∗∗∗ Get a Login URL f o r use with r e d i r e c t s . By de fau l t , f u l l page r e d i r e c t i s∗ assumed . I f you are us ing the generated URL with a window . open ( ) c a l l in∗ JavaScr ipt , you can pass in d i sp l ay=popup as part o f the $params .∗∗ The parameters :∗ − r e d i r e c t u r i : the u r l to go to a f t e r a s u c c e s s f u l l o g i n∗ − scope : comma separated l i s t o f requested extended perms∗∗ @param array $params Provide custom parameters∗ @return s t r i n g The URL f o r the l o g i n f low∗/

pub l i c func t i on getLoginUrl ( $params=array ( ) ) {$th i s−>establishCSRFTokenState ( ) ;$currentUr l = $th i s−>getCurrentUrl ( ) ;

// i f ’ scope ’ i s passed as an array , convert to comma separated l i s t$scopeParams = i s s e t ( $params [ ’ scope ’ ] ) ? $params [ ’ scope ’ ] : nu l l ;i f ( $scopeParams && i s a r r a y ( $scopeParams ) ) {

$params [ ’ scope ’ ] = implode ( ’ , ’ , $scopeParams ) ;}

re turn $th i s−>getUr l (’www’ ,’ d i a l og /oauth ’ ,array merge (

array (’ c l i e n t i d ’ => $th i s−>getAppId ( ) ,’ r e d i r e c t u r i ’ => $currentUrl , // po s s i b l y overwr i t t en’ s tate ’ => $th i s−>s tate ,’ sdk ’ => ’ php−sdk− ’ . s e l f : : VERSION

) ,$params

) ) ;}

/∗∗∗ Get a Logout URL su i t a b l e f o r use with r e d i r e c t s .∗∗ The parameters :∗ − next : the u r l to go to a f t e r a s u c c e s s f u l logout∗∗ @param array $params Provide custom parameters∗ @return s t r i n g The URL f o r the logout f low∗/

pub l i c func t i on getLogoutUrl ( $params=array ( ) ) {re turn $th i s−>getUr l (

’www’ ,’ l ogout . php ’ ,array merge ( array (

’ next ’ => $th i s−>getCurrentUrl ( ) ,’ acce s s token ’ => $th i s−>getUserAccessToken ( ) ,

) , $params )) ;

}

/∗∗∗ Get a l o g i n s t a tu s URL to f e t ch the s ta tu s from Facebook .∗∗ @param array $params Provide custom parameters∗ @return s t r i n g The URL f o r the logout f low∗/

pub l i c func t i on getLog inStatusUr l ( $params=array ( ) ) {re turn $th i s−>getLoginUrl (

array merge ( array (’ re sponse type ’ => ’ code ’ ,’ d i sp lay ’ => ’ none ’ ,

) , $params )) ;

}

/∗∗∗ Make an API c a l l .∗∗ @return mixed The decoded response∗/

pub l i c func t i on api (/∗ polymorphic ∗/) {$args = fun c g e t a r g s ( ) ;i f ( i s a r r a y ( $args [ 0 ] ) ) {

re turn $th i s−> r e s t s e r v e r ( $args [ 0 ] ) ;} e l s e {

re turn c a l l u s e r f u n c a r r a y ( array ( $th i s , ’ graph ’ ) , $args ) ;}

}

/∗∗∗ Constructs and re tu rns the name o f the cook i e that∗ po t e n t i a l l y houses the s igned reques t f o r the app user .∗ The cook i e i s not s e t by the BaseFacebook c l a s s , but∗ i t may be s e t by the JavaScr ipt SDK.∗∗ @return s t r i n g the name o f the cook i e that would house∗ the s igned reques t value .∗/

protec ted func t i on getSignedRequestCookieName ( ) {

233

Page 245: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

re turn ’ f b s r ’ . $ th i s−>getAppId ( ) ;}

/∗∗∗ Constructs and re tu rns the name o f the cook i e that p o t e n t i a l l y conta in∗ metadata . The cook i e i s not s e t by the BaseFacebook c l a s s , but i t may be∗ s e t by the JavaScr ipt SDK.∗∗ @return s t r i n g the name o f the cook i e that would house metadata .∗/

protec ted func t i on getMetadataCookieName ( ) {re turn ’ fbm ’ . $th i s−>getAppId ( ) ;

}

/∗∗∗ Get the au tho r i z a t i on code from the query parameters , i f i t e x i s t s ,∗ and otherwi se return f a l s e to s i g n a l no au tho r i z a t i on code was∗ d i s c ov e r ab l e .∗∗ @return mixed The autho r i z a t i on code , or f a l s e i f the au tho r i z a t i on∗ code could not be determined .∗/

protec ted func t i on getCode ( ) {i f ( ! i s s e t ($ REQUEST[ ’ code ’ ] ) | | ! i s s e t ($ REQUEST[ ’ s tate ’ ] ) ) {

re turn f a l s e ;}i f ( $ th i s−>s t a t e === $ REQUEST[ ’ s tate ’ ] ) {

// CSRF s t a t e has done i t s job , so c l e a r i t$th i s−>s t a t e = nu l l ;$ th i s−>c l e a rPe r s i s t en tData ( ’ s tate ’ ) ;r e turn $ REQUEST[ ’ code ’ ] ;

}s e l f : : e r rorLog ( ’CSRF s t a t e token does not match one provided . ’ ) ;

r e turn f a l s e ;}

/∗∗∗ Ret r i eve s the UID with the understanding that∗ $th i s−>accessToken has a l ready been s e t and i s∗ seemingly l e g i t ima t e . I t r e l i e s on Facebook ’ s Graph API∗ to r e t r i e v e user in format ion and then ex t ra c t∗ the user ID .∗∗ @return i n t e g e r Returns the UID of the Facebook user , or 0∗ i f the Facebook user could not be determined .∗/

protec ted func t i on getUserFromAccessToken ( ) {t ry {

$u s e r i n f o = $th i s−>api ( ’/me ’ ) ;r e turn $u s e r i n f o [ ’ id ’ ] ;

} catch ( FacebookApiException $e ) {re turn 0 ;

}}

/∗∗∗ Returns the acc e s s token that should be used f o r logged out∗ use r s when no autho r i z a t i on code i s a v a i l a b l e .∗∗ @return s t r i n g The app l i c a t i on acc e s s token , u s e f u l f o r gather ing∗ pub l i c in format ion about use r s and app l i c a t i o n s .∗/

pub l i c func t i on getAppl icat ionAccessToken ( ) {re turn $th i s−>appId . ’ | ’ . $ th i s−>appSecret ;

}

/∗∗∗ Lays down a CSRF s t a t e token f o r t h i s p roce s s .∗∗ @return void∗/

protec ted func t i on establishCSRFTokenState ( ) {i f ( $ th i s−>s t a t e === nu l l ) {

$th i s−>s t a t e = md5( uniq id (mt rand ( ) , t rue ) ) ;$ th i s−>s e tPe r s i s t en tData ( ’ s tate ’ , $ th i s−>s t a t e ) ;

}}

/∗∗∗ Ret r i eve s an acc e s s token f o r the given au tho r i z a t i on code∗ ( p r ev i ou s l y generated from www. facebook . com on beha l f o f∗ a s p e c i f i c user ) . The au tho r i z a t i on code i s sent to graph . facebook . com∗ and a l e g i t ima t e ac c e s s token i s generated provided the ac c e s s token∗ and the user f o r which i t was generated a l l match , and the user i s∗ e i t h e r logged in to Facebook or has granted an o f f l i n e a c c e s s permiss ion .∗∗ @param s t r i n g $code An autho r i z a t i on code .∗ @param s t r i n g $ r e d i r e c t u r i Optional r e d i r e c t URI . Defau l t nu l l∗∗ @return mixed An acce s s token exchanged f o r the au tho r i z a t i on code , or∗ f a l s e i f an acc e s s token could not be generated .∗/

protec ted func t i on getAccessTokenFromCode ( $code , $ r e d i r e c t u r i = nu l l ) {i f ( empty ( $code ) ) {

re turn f a l s e ;}

i f ( $ r e d i r e c t u r i === nu l l ) {

234

Page 246: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ r e d i r e c t u r i = $th i s−>getCurrentUrl ( ) ;}

t ry {// need to circumvent j son decode by c a l l i n g oauthRequest// d i r e c t l y , s i n c e response isn ’ t JSON format .$a c c e s s t ok en r e spon s e =

$th i s−> oauthRequest ($th i s−>getUr l ( ’ graph ’ , ’/ oauth/ acces s token ’ ) ,$params = array ( ’ c l i e n t i d ’ => $th i s−>getAppId ( ) ,

’ c l i e n t s e c r e t ’ => $th i s−>getAppSecret ( ) ,’ r e d i r e c t u r i ’ => $ r e d i r e c t u r i ,’ code ’ => $code ) ) ;

} catch ( FacebookApiException $e ) {// most l i k e l y that user very r e c en t l y revoked autho r i z a t i on .// In any event , we don ’ t have an acc e s s token , so say so .re turn f a l s e ;

}

i f ( empty ( $ac c e s s t ok en r e spon s e ) ) {re turn f a l s e ;

}

$response params = array ( ) ;p a r s e s t r ( $acce s s token re sponse , $response params ) ;i f ( ! i s s e t ( $response params [ ’ acce s s token ’ ] ) ) {

re turn f a l s e ;}

re turn $response params [ ’ acce s s token ’ ] ;}

/∗∗∗ Invoke the old r e s t s e r v e r . php endpoint .∗∗ @param array $params Method c a l l ob j e c t∗∗ @return mixed The decoded response ob j e c t∗ @throws FacebookApiException∗/

protec ted func t i on r e s t s e r v e r ( $params ) {// gene r i c app l i c a t i on l e v e l parameters$params [ ’ api key ’ ] = $th i s−>getAppId ( ) ;$params [ ’ format ’ ] = ’ json−s t r i ng s ’ ;

$ r e s u l t = j son decode ( $th i s−> oauthRequest ($th i s−>getApiUrl ( $params [ ’ method ’ ] ) ,$params

) , t rue ) ;

// r e s u l t s are returned , e r r o r s are throwni 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 ro r code ’ ] ) ) {

$th i s−>throwAPIException ( $ r e s u l t ) ;// @codeCoverageIgnoreStart

}// @codeCoverageIgnoreEnd

$method = s t r t o l owe r ( $params [ ’ method ’ ] ) ;i f ( $method === ’ auth . e xp i r e s e s s i on ’ | |

$method === ’ auth . r evokeauthor i za t i on ’ ) {$th i s−>de s t r oySe s s i on ( ) ;

}

re turn $ r e s u l t ;}

/∗∗∗ Return true i f t h i s i s v ideo post .∗∗ @param s t r i n g $path The path∗ @param s t r i n g $method The http method ( d e f au l t ’GET’ )∗∗ @return boolean true i f t h i s i s v ideo post∗/

protec ted func t i on i sVideoPost ( $path , $method = ’GET’ ) {i f ( $method == ’POST’ && preg match (”/ˆ(\/) ( .+) (\/) ( v ideos ) $ /” , $path ) ) {

re turn true ;}re turn f a l s e ;

}

/∗∗∗ Invoke the Graph API .∗∗ @param s t r i n g $path The path ( r equ i r ed )∗ @param s t r i n g $method The http method ( d e f au l t ’GET’ )∗ @param array $params The query/ post data∗∗ @return mixed The decoded response ob j e c t∗ @throws FacebookApiException∗/

protec ted func t i on graph ( $path , $method = ’GET’ , $params = array ( ) ) {i f ( i s a r r a y ( $method ) && empty ( $params ) ) {

$params = $method ;$method = ’GET’ ;

}$params [ ’ method ’ ] = $method ; // method ove r r i d e as we always do a POST

i f ( $th i s−>i sVideoPost ( $path , $method ) ) {

235

Page 247: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$domainKey = ’ graph video ’ ;} e l s e {

$domainKey = ’ graph ’ ;}

$ r e s u l t = j son decode ( $th i s−> oauthRequest ($th i s−>getUr l ( $domainKey , $path ) ,$params

) , t rue ) ;

// r e s u l t s are returned , e r r o r s are throwni 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 ror ’ ] ) ) {

$th i s−>throwAPIException ( $ r e s u l t ) ;// @codeCoverageIgnoreStart

}// @codeCoverageIgnoreEnd

return $ r e s u l t ;}

/∗∗∗ Make a OAuth Request .∗∗ @param s t r i n g $ur l The path ( r equ i r ed )∗ @param array $params The query/ post data∗∗ @return s t r i n g The decoded response ob j e c t∗ @throws FacebookApiException∗/

protec ted func t i on oauthRequest ( $ur l , $params ) {i f ( ! i s s e t ( $params [ ’ acce s s token ’ ] ) ) {

$params [ ’ acce s s token ’ ] = $th i s−>getAccessToken ( ) ;}

i f ( i s s e t ( $params [ ’ acce s s token ’ ] ) && ! i s s e t ( $params [ ’ appsec r e t p roo f ’ ] ) ) {$params [ ’ appsec r e t p roo f ’ ] = $th i s−>getAppSecretProof ( $params [ ’ acce s s token ’ ] ) ;

}

// j son encode a l l params va lues that are not s t r i n g sfo r each ( $params as $key => $value ) {

i f ( ! i s s t r i n g ( $value ) && ! ( $value i n s t an c e o f CURLFile ) ) {$params [ $key ] = json encode ( $value ) ;

}}

re turn $th i s−>makeRequest ( $url , $params ) ;}

/∗∗∗ Generate a proo f o f App Sec re t∗ This i s r equ i r ed 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 rv e r∗ I t i s a sha256 hash o f the ac c e s s t oken made us ing the app s e c r e t∗∗ @param s t r i n g $acce s s token The acc e s s t oken to be hashed ( r equ i r ed )∗∗ @return s t r i n g The sha256 hash o f the acc e s s t oken∗/

protec ted func t i on getAppSecretProof ( $acce s s token ) {re turn hash hmac ( ’ sha256 ’ , $acces s token , $th i s−>getAppSecret ( ) ) ;

}

/∗∗∗ Makes an HTTP reques t . This method can be overr idden by subc l a s s e s i f∗ deve lope r s want to do f a n c i e r th ings or use something other than cu r l to∗ make the reques t .∗∗ @param s t r i n g $ur l The URL to make the reques t to∗ @param array $params The parameters to use f o r the POST body∗ @param CurlHandler $ch I n i t i a l i z e d cu r l handle∗∗ @return s t r i n g The response text∗/

protec ted func t i on makeRequest ( $ur l , $params , $ch=nu l l ) {i f ( ! $ch ) {

$ch = c u r l i n i t ( ) ;}

$opts = s e l f : : $CURL OPTS;i f ( $ th i s−>getFi leUploadSupport ( ) ) {

$opts [CURLOPT POSTFIELDS] = $params ;} e l s e {

$opts [CURLOPT POSTFIELDS] = ht tp bu i l d que ry ( $params , nul l , ’& ’) ;}$opts [CURLOPT URL] = $ur l ;

// d i s ab l e the ’ Expect : 100−continue ’ behaviour . This causes CURL to wait// f o r 2 seconds i f the s e r v e r does not support t h i s header .i f ( i s s e t ( $opts [CURLOPTHTTPHEADER] ) ) {

$ ex i s t i n g h e ad e r s = $opts [CURLOPTHTTPHEADER] ;$ e x i s t i n g h e ad e r s [ ] = ’ Expect : ’ ;$opts [CURLOPTHTTPHEADER] = $ex i s t i n g h e ad e r s ;

} e l s e {$opts [CURLOPTHTTPHEADER] = array ( ’ Expect : ’ ) ;

}

c u r l s e t o p t a r r a y ( $ch , $opts ) ;$ r e s u l t = cu r l e x e c ( $ch ) ;

$errno = cu r l e r r n o ( $ch ) ;

236

Page 248: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

// CURLE SSL CACERT | | CURLE SSL CACERT BADFILEi f ( $errno == 60 | | $errno == 77) {

s e l f : : e r rorLog ( ’ I nva l i d or no c e r t i f i c a t e author i ty found , ’ .’ us ing bundled informat ion ’ ) ;

c u r l s e t o p t ( $ch , CURLOPT CAINFO,dirname ( FILE ) . DIRECTORY SEPARATOR . ’ f b ca cha in bund l e . crt ’ ) ;

$ r e s u l t = cu r l e x e c ( $ch ) ;}

// With dual stacked DNS responses , i t ’ s p o s s i b l e f o r a s e r v e r to// have IPv6 enabled but not have IPv6 connec t i v i t y . I f t h i s i s// the case , c u r l w i l l t ry IPv4 f i r s t and i f that f a i l s , then i t w i l l// f a l l back to IPv6 and the e r r o r EHOSTUNREACH i s returned by the// operat ing system .i f ( $ r e s u l t === f a l s e && empty ( $opts [CURLOPT IPRESOLVE] ) ) {

$matches = array ( ) ;$regex = ’/ Fa i l ed to connect to ( [ ˆ : ] . ∗ ) : Network i s unreachable / ’ ;i f ( preg match ( $regex , c u r l e r r o r ( $ch ) , $matches ) ) {

i f ( s t r l e n ( @inet pton ( $matches [ 1 ] ) ) === 16) {s e l f : : e r rorLog ( ’ I nva l i d IPv6 con f i gu r a t i on on server , ’ .

’ P lease d i s ab l e or get nat ive IPv6 on your 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 = cu r l e x e c ( $ch ) ;

}}

}

i f ( $ r e s u l t === f a l s e ) {$e = new FacebookApiException ( array (

’ e r ro r code ’ => c u r l e r r n o ( $ch ) ,’ e r ror ’ => array (’ message ’ => c u r l e r r o r ( $ch ) ,’ type ’ => ’ CurlException ’ ,) ,

) ) ;c u r l c l o s e ( $ch ) ;throw $e ;

}c u r l c l o s e ( $ch ) ;re turn $ r e s u l t ;

}

/∗∗∗ Parses a s i gn ed r eque s t and va l i d a t e s the s i gna tu r e .∗∗ @param s t r i n g $ s i gned r eque s t A s igned token∗∗ @return array The payload i n s i d e i t or nu l l i f the s i g i s wrong∗/

protec ted func t i on parseSignedRequest ( $ s i gn ed r eque s t ) {

i f ( ! $ s i gned r eque s t | | s t rpo s ( $ s i gned reques t , ’ . ’ ) === f a l s e ) {s e l f : : e r rorLog ( ’ Signed reques t was i n v a l i d ! ’ ) ;r e turn nu l l ;

}

l i s t ( $encoded s ig , $payload ) = explode ( ’ . ’ , $ s i gned reques t , 2) ;

// decode the data$ s i g = s e l f : : base64UrlDecode ( $encoded s ig ) ;$data = json decode ( s e l f : : base64UrlDecode ( $payload ) , t rue ) ;

i f ( ! i s s e t ( $data [ ’ a lgorithm ’ ] )| | s t r toupper ( $data [ ’ algorithm ’ ] ) !== s e l f : : SIGNED REQUEST ALGORITHM

) {s e l f : : e r rorLog (

’Unknown algor i thm . Expected ’ . s e l f : : SIGNED REQUEST ALGORITHM) ;return nu l l ;

}

// check s i g$ expec t ed s i g = hash hmac ( ’ sha256 ’ , $payload ,

$th i s−>getAppSecret ( ) , $raw = true ) ;

i f ( s t r l e n ( $ expec t ed s i g ) !== s t r l e n ( $ s i g ) ) {s e l f : : e r rorLog ( ’Bad Signed JSON s igna tu r e ! ’ ) ;r e turn nu l l ;

}

$ r e s u l t = 0 ;f o r ( $ i = 0 ; $ i < s t r l e n ( $ expec t ed s i g ) ; $ i++) {

$ r e s u l t |= ord ( $expec t ed s i g [ $ i ] ) ˆ ord ( $ s i g [ $ i ] ) ;}

i f ( $ r e s u l t == 0) {re turn $data ;

} e l s e {s e l f : : e r rorLog ( ’Bad Signed JSON s igna tu r e ! ’ ) ;r e turn nu l l ;

}}

/∗∗∗ Makes a s i gn ed r eque s t blob us ing the given data .∗∗ @param array $data The data array .∗∗ @return s t r i n g The s igned reques t .

237

Page 249: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗/protec ted func t i on makeSignedRequest ( $data ) {

i f ( ! i s a r r a y ( $data ) ) {throw new InvalidArgumentException (

’ makeSignedRequest expects an array . Got : ’ . p r i n t r ( $data , t rue ) ) ;}$data [ ’ algorithm ’ ] = s e l f : : SIGNED REQUEST ALGORITHM;$data [ ’ i s sued a t ’ ] = time ( ) ;$ j son = json encode ( $data ) ;$b64 = s e l f : : base64UrlEncode ( $ j son ) ;$ raw s ig = hash hmac ( ’ sha256 ’ , $b64 , $th i s−>getAppSecret ( ) , $raw = true ) ;$ s i g = s e l f : : base64UrlEncode ( $raw s ig ) ;r e turn $ s i g . ’ . ’ . $b64 ;

}

/∗∗∗ Build the URL f o r api g iven parameters .∗∗ @param s t r i n g $method The method name .∗∗ @return s t r i n g The URL f o r the given parameters∗/

protec ted func t i on getApiUrl ( $method ) {s t a t i c $READ ONLY CALLS =

array ( ’ admin . g e t a l l o c a t i on ’ => 1 ,’ admin . ge tappproper t i e s ’ => 1 ,’ admin . getbannedusers ’ => 1 ,’ admin . g e t l i v e s t r e amv i a l i nk ’ => 1 ,’ admin . getmetr i c s ’ => 1 ,’ admin . g e t r e s t r i c t i o n i n f o ’ => 1 ,’ app l i c a t i on . g e tpub l i c i n f o ’ => 1 ,’ auth . getapppubl ickey ’ => 1 ,’ auth . g e t s e s s i on ’ => 1 ,’ auth . g e t s i gnedpub l i c s e s s i onda ta ’ => 1 ,’ comments . get ’ => 1 ,’ connect . getunconnected f r i endscount ’ => 1 ,’ dashboard . g e t a c t i v i t y ’ => 1 ,’ dashboard . getcount ’ => 1 ,’ dashboard . getg lobalnews ’ => 1 ,’ dashboard . getnews ’ => 1 ,’ dashboard . mult igetcount ’ => 1 ,’ dashboard . multigetnews ’ => 1 ,’ data . ge tcook i e s ’ => 1 ,’ events . get ’ => 1 ,’ events . getmembers ’ => 1 ,’ fbml . getcustomtags ’ => 1 ,’ f e ed . g e t app f r i e nd s t o r i e s ’ => 1 ,’ f e ed . ge t r eg i s t e r edtemplatebund l eby id ’ => 1 ,’ f e ed . ge t r eg i s t e r ed t emp la t ebund l e s ’ => 1 ,’ f q l . multiquery ’ => 1 ,’ f q l . query ’ => 1 ,’ f r i e n d s . a r e f r i e nd s ’ => 1 ,’ f r i e n d s . get ’ => 1 ,’ f r i e n d s . getappusers ’ => 1 ,’ f r i e n d s . g e t l i s t s ’ => 1 ,’ f r i e n d s . getmutua l f r i ends ’ => 1 ,’ g i f t s . get ’ => 1 ,’ groups . get ’ => 1 ,’ groups . getmembers ’ => 1 ,’ i n t l . g e t t r an s l a t i on s ’ => 1 ,’ l i n k s . get ’ => 1 ,’ notes . get ’ => 1 ,’ n o t i f i c a t i o n s . get ’ => 1 ,’ pages . g e t in f o ’ => 1 ,’ pages . isadmin ’ => 1 ,’ pages . isappadded ’ => 1 ,’ pages . i s f an ’ => 1 ,’ pe rmi s s i ons . ch e ckava i l ab l e ap i a c c e s s ’ => 1 ,’ pe rmi s s i ons . checkgrantedap iacces s ’ => 1 ,’ photos . get ’ => 1 ,’ photos . getalbums ’ => 1 ,’ photos . gettags ’ => 1 ,’ p r o f i l e . g e t in f o ’ => 1 ,’ p r o f i l e . g e t i n f oop t i on s ’ => 1 ,’ stream . get ’ => 1 ,’ stream . getcomments ’ => 1 ,’ stream . g e t f i l t e r s ’ => 1 ,’ u s e r s . g e t in f o ’ => 1 ,’ u s e r s . g e t l ogged inuse r ’ => 1 ,’ u s e r s . ge t s tandard in fo ’ => 1 ,’ u s e r s . hasapppermiss ion ’ => 1 ,’ u s e r s . i sappuser ’ => 1 ,’ u s e r s . i s v e r i f i e d ’ => 1 ,’ v ideo . ge tup load l im i t s ’ => 1) ;

$name = ’ api ’ ;i f ( i s s e t ($READ ONLY CALLS[ s t r t o l owe r ( $method ) ] ) ) {

$name = ’ api read ’ ;} e l s e i f ( s t r t o l owe r ( $method ) == ’ video . upload ’ ) {

$name = ’ ap i v ideo ’ ;}re turn s e l f : : getUr l ($name , ’ r e s t s e r v e r . php ’ ) ;

}

/∗∗∗ Build the URL f o r given domain a l i a s , path and parameters .∗∗ @param s t r i n g $name The name o f the domain∗ @param s t r i n g $path Optional path ( without a l ead ing s l a sh )∗ @param array $params Optional query parameters

238

Page 250: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗∗ @return s t r i n g The URL f o r the given parameters∗/

protec ted func t i on getUr l ($name , $path= ’ ’ , $params=array ( ) ) {$ur l = s e l f : : $DOMAIN MAP[ $name ] ;i f ( $path ) {

i f ( $path [ 0 ] === ’/ ’ ) {$path = subst r ( $path , 1) ;

}$ur l .= $path ;

}i f ( $params ) {

$ur l .= ’? ’ . h t tp bu i l d que ry ( $params , nul l , ’& ’) ;}

re turn $ur l ;}

/∗∗∗ Returns the HTTP Host∗∗ @return s t r i n g The HTTP Host∗/

protec ted func t i on getHttpHost ( ) {i f ( $ th i s−>trustForwarded && i s s e t ($ SERVER[ ’HTTP X FORWARDED HOST’ ] ) ) {

$forwardProxies = explode ( ’ , ’ , $ SERVER[ ’HTTP X FORWARDED HOST’ ] ) ;i f ( ! empty ( $ forwardProxies ) ) {

re turn $forwardProxies [ 0 ] ;}

}re turn $ SERVER[ ’HTTP HOST’ ] ;

}

/∗∗∗ Returns the HTTP Protoco l∗∗ @return s t r i n g The HTTP Protoco l∗/

protec ted func t i on getHttpProtoco l ( ) {i f ( $ th i s−>trustForwarded && i s s e t ($ SERVER[ ’HTTP X FORWARDED PROTO’ ] ) ) {

i f ($ SERVER[ ’HTTP X FORWARDED PROTO’ ] === ’ https ’ ) {re turn ’ https ’ ;

}re turn ’ http ’ ;

}/∗apache + var i an t s s p e c i f i c way o f checking f o r https ∗/i f ( i s s e t ($ SERVER[ ’HTTPS’ ] ) &&

($ SERVER[ ’HTTPS’ ] === ’on ’ | | $ SERVER[ ’HTTPS’ ] == 1) ) {re turn ’ https ’ ;

}/∗nginx way o f checking f o r https ∗/i f ( i s s e t ($ SERVER[ ’SERVER PORT’ ] ) &&

($ SERVER[ ’SERVER PORT’ ] === ’443 ’ ) ) {re turn ’ https ’ ;

}re turn ’ http ’ ;

}

/∗∗∗ Returns the base domain used f o r the cook i e .∗∗ @return s t r i n g The base domain∗/

protec ted func t i on getBaseDomain ( ) {// The base domain i s s to red in the metadata cook i e i f not we f a l l b a c k// to the cur rent hostname$metadata = $th i s−>getMetadataCookie ( ) ;i f ( a r r a y k e y e x i s t s ( ’ base domain ’ , $metadata ) &&

! empty ( $metadata [ ’ base domain ’ ] ) ) {re turn trim ( $metadata [ ’ base domain ’ ] , ’ . ’ ) ;

}re turn $th i s−>getHttpHost ( ) ;

}

/∗∗∗ Returns the Current URL, s t r i pp i n g i t o f known FB parameters that should∗ not p e r s i s t .∗∗ @return s t r i n g The current URL∗/

protec ted func t i on getCurrentUrl ( ) {$pro toco l = $th i s−>getHttpProtoco l ( ) . ’ : / / ’ ;$host = $th i s−>getHttpHost ( ) ;$currentUr l = $pro toco l . $host . $ SERVER[ ’REQUEST URI ’ ] ;$part s = pa r s e u r l ( $currentUr l ) ;

$query = ’ ’ ;i f ( ! empty ( $parts [ ’ query ’ ] ) ) {

// drop known fb params$params = explode ( ’& ’ , $parts [ ’ query ’ ] ) ;$reta ined params = array ( ) ;f o r each ( $params as $param) {

i f ( $ th i s−>shouldRetainParam ($param) ) {$reta ined params [ ] = $param ;

}}

i f ( ! empty ( $reta ined params ) ) {$query = ’ ? ’ . implode ( $retained params , ’& ’) ;

239

Page 251: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}}

// use port i f non de f au l t$port =

i s s e t ( $parts [ ’ port ’ ] ) &&(( $pro toco l === ’ http : // ’ && $parts [ ’ port ’ ] !== 80) | |( $pro toco l === ’ https : // ’ && $parts [ ’ port ’ ] !== 443) )

? ’ : ’ . $part s [ ’ port ’ ] : ’ ’ ;

// r ebu i l dreturn $pro toco l . $part s [ ’ host ’ ] . $port . $parts [ ’ path ’ ] . $query ;

}

/∗∗∗ Returns t rue i f and only i f the key or key/ value pa i r should∗ be r e ta ined as part o f the query s t r i n g . This amounts to∗ a brute−f o r c e search o f the very smal l l i s t o f Facebook−s p e c i f i c∗ params that should be s t r i pped out .∗∗ @param s t r i n g $param A key or key/ value pa i r with in a URL’ s query ( e . g .∗ ’ f oo=a ’ , ’ foo = ’ , or ’ foo ’ .∗∗ @return boolean∗/

protec ted func t i on shouldRetainParam ($param) {f o r each ( s e l f : : $DROP QUERY PARAMS as $drop query param ) {

i f ( $param === $drop query param | |s t rpo s ( $param , $drop query param . ’= ’) === 0) {

re turn f a l s e ;}

}

re turn true ;}

/∗∗∗ Analyzes the supp l i ed r e s u l t to see i f i t was thrown∗ because the ac c e s s token i s no longe r va l i d . I f that i s∗ the case , then we dest roy the s e s s i o n .∗∗ @param array $ r e s u l t A record s t o r i n g the e r r o r message returned∗ by a f a i l e d API c a l l .∗/

protec ted func t i on throwAPIException ( $ r e s u l t ) {$e = new FacebookApiException ( $ r e s u l t ) ;switch ( $e−>getType ( ) ) {

// OAuth 2 .0 Draft 00 s t y l ecase ’OAuthException ’ :

// OAuth 2 .0 Draft 10 s t y l ecase ’ i nva l i d token ’ :

// REST se rv e r e r r o r s are j u s t Except ionscase ’ Exception ’ :

$message = $e−>getMessage ( ) ;i f ( ( s t rpo s ( $message , ’ Error va l i d a t i n g ac c e s s token ’ ) !== f a l s e ) | |

( s t rpo s ( $message , ’ I nva l i d OAuth acc e s s token ’ ) !== f a l s e ) | |( s t rpo s ( $message , ’An ac t i v e ac c e s s token must be used ’ ) !== f a l s e )

) {$th i s−>de s t r oySe s s i on ( ) ;

}break ;

}

throw $e ;}

/∗∗∗ Pr int s to the e r r o r l og i f you aren ’ t in command l i n e mode .∗∗ @param s t r i n g $msg Log message∗/

protec ted s t a t i c func t i on errorLog ($msg ) {// d i s ab l e e r r o r log i f we are running in a CLI environment// @codeCoverageIgnoreStarti f ( php sapi name ( ) != ’ c l i ’ ) {

e r r o r l o g ( $msg ) ;}// uncomment t h i s i f you want to see the e r r o r s on the page// pr in t ’ e r r o r l o g : ’ . $msg .”\n ” ;// @codeCoverageIgnoreEnd

}

/∗∗∗ Base64 encoding that doesn ’ t need to be ur lencode ( ) ed .∗ Exactly the same as base64 encode except i t uses∗ − i n s t ead o f +∗ i n s t ead o f /∗ No padded =∗∗ @param s t r i n g $input base64UrlEncoded input∗∗ @return s t r i n g The decoded s t r i n g∗/

protec ted s t a t i c func t i on base64UrlDecode ( $input ) {re turn base64 decode ( s t r t r ( $input , ’− ’ , ’+/ ’) ) ;

}

/∗∗

240

Page 252: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗ Base64 encoding that doesn ’ t need to be ur lencode ( ) ed .∗ Exactly the same as base64 encode except i t uses∗ − i n s t ead o f +∗ i n s t ead o f /∗∗ @param s t r i n g $input The input to encode∗ @return s t r i n g The base64Url encoded input , as a s t r i n g .∗/

protec ted s t a t i c func t i on base64UrlEncode ( $input ) {$ s t r = s t r t r ( base64 encode ( $input ) , ’+/ ’ , ’− ’ ) ;$ s t r = s t r r e p l a c e ( ’= ’ , ’ ’ , $ s t r ) ;r e turn $ s t r ;

}

/∗∗∗ Destroy the cur rent s e s s i o n∗/

pub l i c func t i on de s t roySe s s i on ( ) {$th i s−>accessToken = nu l l ;$ th i s−>s ignedRequest = nu l l ;$ th i s−>user = nu l l ;$ th i s−>c l e a rA l lPe r s i s t en tDa ta ( ) ;

// Javas c r ip t s e t s a cook i e that w i l l be used in getSignedRequest that we// need to c l e a r i f we can$cookie name = $th i s−>getSignedRequestCookieName ( ) ;i f ( a r r a y k e y e x i s t s ( $cookie name , $ COOKIE) ) {

unset ($ COOKIE [ $cookie name ] ) ;i f ( ! h eade r s s en t ( ) ) {

$base domain = $th i s−>getBaseDomain ( ) ;s e t c o ok i e ( $cookie name , ’ ’ , 1 , ’ / ’ , ’ . ’ . $base domain ) ;

} e l s e {// @codeCoverageIgnoreStarts e l f : : e r rorLog (

’ There e x i s t s a cook i e that we wanted to c l e a r that we couldn \ ’ t ’ .’ c l e a r because headers was a l ready sent . Make sure to do the f i r s t ’ .’API c a l l b e f o r e outputing anything . ’

) ;// @codeCoverageIgnoreEnd

}}

}

/∗∗∗ Parses the metadata cook i e that our Javas c r ip t API s e t∗∗ @return array an array mapping key to value∗/

protec ted func t i on getMetadataCookie ( ) {$cookie name = $th i s−>getMetadataCookieName ( ) ;i f ( ! a r r a y k e y e x i s t s ( $cookie name , $ COOKIE) ) {

re turn array ( ) ;}

// The cook ie value can be wrapped in ”−cha ra c t e r s so remove them$cook i e va lue = trim ($ COOKIE [ $cookie name ] , ’ ” ’ ) ;

i f ( empty ( $cook i e va lue ) ) {re turn array ( ) ;

}

$part s = explode ( ’& ’ , $ cook i e va lue ) ;$metadata = array ( ) ;f o r each ( $parts as $part ) {

$pa i r = explode ( ’= ’ , $part , 2) ;i f ( ! empty ( $pa i r [ 0 ] ) ) {

$metadata [ ur ldecode ( $pa i r [ 0 ] ) ] =( count ( $pa i r ) > 1) ? ur ldecode ( $pa i r [ 1 ] ) : ’ ’ ;

}}

re turn $metadata ;}

/∗∗∗ Finds whether the given domain i s a l lowed or not∗∗ @param s t r i n g $big The value to be checked aga in s t $smal l∗ @param s t r i n g $smal l The input s t r i n g∗∗ @return boolean Returns TRUE i f $big matches $smal l∗/

protec ted s t a t i c func t i on isAllowedDomain ( $big , $smal l ) {i f ( $big === $smal l ) {

re turn true ;}re turn s e l f : : endsWith ( $big , ’ . ’ . $smal l ) ;

}

/∗∗∗ Checks i f $big s t r i n g ends with $smal l s t r i n g∗∗ @param s t r i n g $big The value to be checked aga in s t $smal l∗ @param s t r i n g $smal l The input s t r i n g∗∗ @return boolean TRUE i f $big ends with $smal l∗/

protec ted s t a t i c func t i on endsWith ( $big , $smal l ) {$ len = s t r l e n ( $smal l ) ;

241

Page 253: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

i f ( $ l en === 0) {re turn true ;

}re turn subs t r ( $big , −$ len ) === $smal l ;

}

/∗∗∗ Each o f the f o l l ow ing four methods should be overr idden in∗ a concre t e subc las s , as they are in the provided Facebook c l a s s .∗ The Facebook c l a s s uses PHP s e s s i o n s to provide a p r im i t i v e∗ p e r s i s t e n t s tore , but another subc las s−−one that you implement−−∗ might use a database , memcache , or an in−memory cache .∗∗ @see Facebook∗/

/∗∗∗ Store s the given ( $key , $value ) pair , so that fu tu r e c a l l s to∗ getPer s i s t entData ( $key ) return $value . This c a l l may be in another r eques t .∗∗ @param s t r i n g $key∗ @param array $value∗∗ @return void∗/

abs t rac t protec ted func t i on s e tPe r s i s t en tData ( $key , $value ) ;

/∗∗∗ Get the data f o r $key , p e r s i s t e d by BaseFacebook : : s e tPe r s i s t en tData ( )∗∗ @param s t r i n g $key The key o f the data to r e t r i e v e∗ @param boolean $de f au l t The de f au l t value to return i f $key i s not found∗∗ @return mixed∗/

abs t rac t protec ted func t i on ge tPer s i s t entData ( $key , $de f au l t = f a l s e ) ;

/∗∗∗ Clear the data with $key from the p e r s i s t e n t s to rage∗∗ @param s t r i n g $key∗∗ @return void∗/

abs t rac t protec ted func t i on c l e a rPe r s i s t en tData ( $key ) ;

/∗∗∗ Clear a l l data from the p e r s i s t e n t s to rage∗∗ @return void∗/

abs t rac t protec ted func t i on c l e a rA l lPe r s i s t en tDa ta ( ) ;}

<?php i f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;/∗∗∗ Copyright 2011 Facebook , Inc .∗∗ Licensed under the Apache License , Vers ion 2 .0 ( the ” License ”) ; you may∗ not use t h i s f i l e except in compliance with the L icense . You may obta in∗ a copy o f the L icense at∗∗ http ://www. apache . org / l i c e n s e s /LICENSE−2.0∗∗ Unless r equ i r ed by app l i c ab l e law or agreed to in wr i t ing , so f tware∗ d i s t r i bu t ed under the L icense i s d i s t r i bu t ed on an ”AS IS” BASIS , WITHOUT∗ WARRANTIES OR CONDITIONS OF ANY KIND, e i t h e r expre s s or impl i ed . See the∗ License f o r the s p e c i f i c language governing permi s s i ons and l im i t a t i o n s∗ under the L icense .∗/

r equ i r e onc e ” base facebook . php ” ;

/∗∗∗ Extends the BaseFacebook c l a s s with the in t en t o f us ing∗ PHP s e s s i o n s to s t o r e user i d s and acc e s s tokens .∗/

c l a s s Facebook extends BaseFacebook{

/∗∗∗ Cookie p r e f i x∗/

const FBSS COOKIE NAME = ’ fbss ’ ;

/∗∗∗ We can s e t t h i s to a high number because the main s e s s i o n∗ exp i r a t i on w i l l trump th i s .∗/

const FBSS COOKIE EXPIRE = 31556926; // 1 year

/∗∗∗ Store s the shared s e s s i o n ID i f one i s s e t .∗∗ @var s t r i n g∗/

protec ted $sharedSess ionID ;

/∗∗

242

Page 254: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗ I d e n t i c a l to the parent const ructor , except that∗ we s t a r t a PHP s e s s i o n to s t o r e the user ID and∗ acc e s s token i f during the course o f execut ion∗ we d i s cove r them .∗∗ @param array $con f i g the app l i c a t i on con f i gu r a t i on . Add i t i ona l l y∗ accepts ” sharedSes s i on ” as a boolean to turn on a secondary∗ cook i e f o r environments with a shared s e s s i o n ( that i s , your app∗ share s the domain with other apps ) .∗∗ @see BaseFacebook : : c o n s t r u c t∗/

pub l i c func t i on c on s t r u c t ( $ con f i g ) {i f ( ( f u n c t i o n e x i s t s ( ’ s e s s i o n s t a t u s ’ )

&& 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 ( ) ) {s e s s i o n s t a r t ( ) ;

}parent : : c o n s t r u c t ( $ con f i g ) ;i f ( ! empty ( $con f i g [ ’ sharedSess ion ’ ] ) ) {

$th i s−>i n i t Sha r edSe s s i on ( ) ;

// re−load the p e r s i s t e d state , s i n c e parent// attempted to read out o f non−shared cook i e$ s t a t e = $th i s−>getPer s i s t entData ( ’ s tate ’ ) ;i f ( ! empty ( $ s t a t e ) ) {

$th i s−>s t a t e = $s ta t e ;} e l s e {

$th i s−>s t a t e = nu l l ;}

}}

/∗∗∗ Supported keys f o r p e r s i s t e n t data∗∗ @var array∗/

protec ted s t a t i c $kSupportedKeys =array ( ’ s tate ’ , ’ code ’ , ’ acce s s token ’ , ’ u s e r id ’ ) ;

/∗∗∗ I n i t i a t e s Shared Ses s i on∗/

protec ted func t i on i n i t Sha r edSe s s i on ( ) {$cookie name = $th i s−>getSharedSessionCookieName ( ) ;i f ( i s s e t ($ COOKIE [ $cookie name ] ) ) {

$data = $th i s−>parseSignedRequest ($ COOKIE [ $cookie name ] ) ;i f ( $data && ! empty ( $data [ ’ domain ’ ] ) &&

s e l f : : isAllowedDomain ( $th i s−>getHttpHost ( ) , $data [ ’ domain ’ ] ) ) {// good case$th i s−>sharedSess ionID = $data [ ’ id ’ ] ;r e turn ;

}// i gno r ing p o t e n t i a l l y unreachable data

}// e v i l / corrupt /miss ing case$base domain = $th i s−>getBaseDomain ( ) ;$ th i s−>sharedSess ionID = md5( uniq id (mt rand ( ) , t rue ) ) ;$ cook i e va lue = $th i s−>makeSignedRequest (

array (’ domain ’ => $base domain ,’ id ’ => $th i s−>sharedSess ionID ,

)) ;$ COOKIE [ $cookie name ] = $cook i e va lue ;i f ( ! h eade r s s en t ( ) ) {

$exp i r e = time ( ) + s e l f : : FBSS COOKIE EXPIRE ;s e t c ook i e ( $cookie name , $cook i e va lue , $expire , ’ / ’ , ’ . ’ . $base domain ) ;

} e l s e {// @codeCoverageIgnoreStarts e l f : : e r rorLog (

’ Shared s e s s i o n ID cook ie could not be s e t ! You must ensure you ’ .’ c r e a t e the Facebook in s tance be f o r e headers have been sent . This ’ .’ w i l l cause authent i ca t i on i s s u e s a f t e r the f i r s t r eques t . ’

) ;// @codeCoverageIgnoreEnd

}}

/∗∗∗ Provides the implementat ions o f the i nh e r i t e d abs t ra c t∗ methods . The implementation uses PHP s e s s i o n s to maintain∗ a s t o r e f o r au tho r i z a t i on codes , user ids , CSRF sta t e s , and∗ acc e s s tokens .∗/

/∗∗∗ {@inher i tdoc}∗∗ @see BaseFacebook : : s e tPe r s i s t en tData ( )∗/

protec ted func t i on s e tPe r s i s t en tData ( $key , $value ) {i f ( ! i n a r r ay ( $key , s e l f : : $kSupportedKeys ) ) {

s e l f : : e r rorLog ( ’ Unsupported key passed to s e tPe r s i s t en tData . ’ ) ;r e turn ;

}

$ses s ion var name = $th i s−>constructSess ionVar iableName ( $key ) ;

243

Page 255: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ SESSION [ $ses s ion var name ] = $value ;}

/∗∗∗ {@inher i tdoc}∗∗ @see BaseFacebook : : ge tPer s i s t entData ( )∗/

protec ted func t i on ge tPer s i s t entData ( $key , $de f au l t = f a l s e ) {i f ( ! i n a r r ay ( $key , s e l f : : $kSupportedKeys ) ) {

s e l f : : e r rorLog ( ’ Unsupported key passed to ge tPer s i s t entData . ’ ) ;r e turn $de f au l t ;

}

$ses s ion var name = $th i s−>constructSess ionVar iableName ( $key ) ;re turn i s s e t ( $ SESSION [ $ses s ion var name ] ) ?

$ SESSION [ $ses s ion var name ] : $de f au l t ;}

/∗∗∗ {@inher i tdoc}∗∗ @see BaseFacebook : : c l e a rPe r s i s t en tData ( )∗/

protec ted func t i on c l e a rPe r s i s t en tData ( $key ) {i f ( ! i n a r r ay ( $key , s e l f : : $kSupportedKeys ) ) {

s e l f : : e r rorLog ( ’ Unsupported key passed to c l e a rPe r s i s t en tData . ’ ) ;r e turn ;

}

$ses s ion var name = $th i s−>constructSess ionVar iableName ( $key ) ;i f ( i s s e t ( $ SESSION [ $ses s ion var name ] ) ) {

unset ( $ SESSION [ $ses s ion var name ] ) ;}

}

/∗∗∗ {@inher i tdoc}∗∗ @see BaseFacebook : : c l e a rA l lPe r s i s t en tDa ta ( )∗/

protec ted func t i on c l e a rA l lPe r s i s t en tDa ta ( ) {f o r each ( s e l f : : $kSupportedKeys as $key ) {

$th i s−>c l e a rPe r s i s t en tData ( $key ) ;}i f ( $ th i s−>sharedSess ionID ) {

$th i s−>de l e teSharedSes s ionCook ie ( ) ;}

}

/∗∗∗ Dele te s Shared s e s s i o n cook i e∗/

protec ted func t i on de l e teSharedSes s ionCook ie ( ) {$cookie name = $th i s−>getSharedSessionCookieName ( ) ;unset ($ COOKIE [ $cookie name ] ) ;$base domain = $th i s−>getBaseDomain ( ) ;s e t c o ok i e ( $cookie name , ’ ’ , 1 , ’ / ’ , ’ . ’ . $base domain ) ;

}

/∗∗∗ Returns the Shared s e s s i o n cook i e name∗∗ @return s t r i n g The Shared s e s s i o n cook i e name∗/

protec ted func t i on getSharedSessionCookieName ( ) {re turn s e l f : : FBSS COOKIE NAME . ’ ’ . $ th i s−>getAppId ( ) ;

}

/∗∗∗ Constructs and re tu rns the name o f the s e s s i o n key .∗∗ @see s e tPe r s i s t en tData ( )∗ @param s t r i n g $key The key f o r which the s e s s i o n va r i ab l e name to cons t ruc t .∗∗ @return s t r i n g The name o f the s e s s i o n key .∗/

protec ted func t i on constructSess ionVar iableName ( $key ) {$part s = array ( ’ fb ’ , $ th i s−>getAppId ( ) , $key ) ;i f ( $ th i s−>sharedSess ionID ) {

a r r a y un sh i f t ( $parts , $ th i s−>sharedSess ionID ) ;}re turn implode ( ’ ’ , $part s ) ;

}}

<?phpi f ( ! de f ined ( ’BASEPATH’ ) ) e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;/∗∗∗ @name MY Pagination . php∗ @version 1 .0∗ @author Joost van Veen www. a c c e n t i n t e r a c t i v e . n l∗ @created : Sun Jul 27 16 : 27 : 26 GMT 2008 16 : 27 : 26∗∗ A simple Paginat ion extens ion to make working with pag inat ion a b i t e a s i e r .∗ I c reated t h i s l i b because I had URIs in my app in which the paging element∗ was not always in the same segment , which makes i t a pain i f you work with∗ the d e f au l t pag inat ion c l a s s .

244

Page 256: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗∗ This s imple l i b accompl i shes the f o l l ow ing :∗ − I t determines waht the ’ base ur l ’ i s , so you don ’ t have to s e t i t y ou r s e l f∗ − I t removes the need f o r you s e t t i n g the infamous ’ ur i segment ’ s e t t i n g∗∗ Bas i ca l l y , i t s e t s paging at the end o f the ur i , without having to pass a u r i∗ segment . The l i b r a r y r e l i e s on a unique pag inat ion s e l e c t o r , which i t uses to∗ determine i f and where the pagn i t i on o f f s e t i s l o ca t ed in the URI .∗∗ E. g . /example/ pag inat ion /Page/3∗∗ The l i b s ea r che s f o r the p a g i n a t i o n s e l e c t o r ( ’ Page ’ , in the above example )∗ and r e t r a c t s the proper o f f s e t value ( in t h i s case 3)∗∗ The pag inat ion l i n k s are automat i ca l ly created , j u s t as in CI ’ s d e f au l t∗ pag inat ion l i b .∗∗ Requirements∗ Code ign i t e r 2+∗ PHP 5∗ A ∗unique∗ pag inat ion s e l e c t o r ( d e f au l t i s ’ Page ’ ) − unique meaning a s t r i n g∗ you are sure w i l l never appear in the ur i , except f o r pag inat ion .∗∗ I f the re we use paginat ion , i t must ALWAYS fo l l ow the f o l l ow ing syntax and be∗ l o ca t ed at the END of the 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 in the∗ URI when paging i s s e t . Let ’ s say the PAGINATION SELECTOR i s ’Page ’ ( s i n c e most∗ coders never use any c a p i t a l s in the URI , most o f the t imes any s t r i n g with∗ a s i n g l e c a p i t a l charac t e r in i t w i l l s u f f i c e ) .∗∗ Example use ( in c o n t r o l l e r ) :∗ // I n i t i a l i z e pag inat ion∗ $con f i g [ ’ t o ta l rows ’ ] = $th i s−>db−>c o u n t a l l r e s u l t s ( ’ my table ’ ) ;∗ $con f i g [ ’ per page ’ ] = 10 ; // You ’ d best s e t t h i s in a con f i g f i l e , but hey∗ $th i s−>paginat ion−> i n i t i a l i z e ( $ con f i g ) ;∗ $th i s−>data [ ’ paginat ion ’ ] = $th i s−>paginat ion−>c r e a t e l i n k s ( ) ;∗∗ // Retr i eve paginated r e s u l t s , us ing the dynamical ly determined o f f s e t∗ $th i s−>db−>l im i t ( $ con f i g [ ’ per page ’ ] , $ th i s−>paginat ion−>o f f s e t ) ;∗ $query = $th i s−>db−>get ( ’ my table ’ ) ;∗∗/

c l a s s MY Pagination extends CI Paginat ion{

var $ o f f s e t = 0 ;var $p a g i n a t i o n s e l e c t o r = ’Page ’ ;var $ index page ;func t i on MY Pagination ( ){

parent : : c o n s t r u c t ( ) ;log message ( ’ debug ’ , ”MY Pagination Class I n i t i a l i z e d ”) ;

$th i s−>index page = con f i g i t em ( ’ index page ’ ) != ’ ’ ? c on f i g i t em ( ’ index page ’ ) . ’/ ’: ’ ’ ;

$ th i s−> s e t p a g i n a t i o n o f f s e t ( ) ;}/∗∗∗ Set dynamic pag inat ion va r i a b l e s in $CI−>data [ ’ pagvars ’ ]∗∗/

func t i on s e t p a g i n a t i o n o f f s e t ( ){

// I n s t an t i a t e the CI super ob j e c t so we have acc e s s to the u r i c l a s s$CI = & ge t i n s t an c e ( ) ;

// Store pag inat ion o f f s e t i f i t i s s e ti f ( s t r s t r ( $CI−>uri−>u r i s t r i n g ( ) , $ th i s−>pa g i n a t i o n s e l e c t o r ) ) {

// Get the segment o f f s e t f o r the pag inat ion s e l e c t o r$segments = $CI−>uri−>segment array ( ) ;

// Loop through segments to r e t r i e v e pag inat ion o f f s e tf o r each ( $segments as $key => $value ) {

// Find the p a g i n a t i o n s e l e c t o r and work from therei f ( $value == $th i s−>pa g i n a t i o n s e l e c t o r ) {

// Store pag inat ion o f f s e t$th i s−>o f f s e t = $CI−>uri−>segment ( $key + 1) ;

// Store pag inat ion segment$th i s−>ur i segment = $key + 1 ;

// Set base u r l f o r paging . This only works i f the// p a g i n a t i o n s e l e c t o r and paging o f f s e t are AT THE END of// the URI !$ur i = $CI−>uri−>u r i s t r i n g ( ) ;$pos = s t rpo s ( $uri , $ th i s−>pa g i n a t i o n s e l e c t o r ) ;$ th i s−>ba s e u r l = con f i g i t em ( ’ base ur l ’ ) . $ th i s−>index page . subs t r (

$ur i , 0 , $pos + s t r l e n ( $th i s−>pa g i n a t i o n s e l e c t o r ) ) ;}

}

}e l s e { // Paginat ion s e l e c t o r was not found in URI s t r i n g . So o f f s e t i s 0

245

Page 257: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$th i s−>o f f s e t = 0 ;$th i s−>ur i segment = 0 ;$th i s−>ba s e u r l = con f i g i t em ( ’ base ur l ’ ) . $ th i s−>index page . $CI−>uri−>

u r i s t r i n g ( ) . ’/ ’ . $ th i s−>pa g i n a t i o n s e l e c t o r ;

}

}}

<?php/∗∗∗ tmhOAuth∗∗ An OAuth l i b r a r y wr i t t en in PHP.∗ The l i b r a r y supports f i l e uploading us ing mult ipart / form as we l l as gene ra l∗ REST reque s t s . OAuth authent i ca t i on i s sent us ing an Author izat ion Header .∗∗ @author thematthar r i s∗ @version 0 . 8 . 4∗∗ 06 Aug 2014∗/

de f ined ( ’ DIR ’ ) or d e f i n e ( ’ DIR ’ , dirname ( FILE ) ) ;

c l a s s tmhOAuth {const VERSION = ’ 0 . 8 . 4 ’ ;var $response = array ( ) ;

/∗∗∗ Creates a new tmhOAuth ob j e c t∗∗ @param s t r i n g $conf ig , the c on f i gu r a t i on to use f o r t h i s r eques t∗ @return void∗/

pub l i c func t i on c on s t r u c t ( $ con f i g=array ( ) ) {$th i s−>bu f f e r = nu l l ;$ th i s−>r e c on f i gu r e ( $ con f i g ) ;$ th i s−>r e s e t r e q u e s t s e t t i n g s ( ) ;$ th i s−>s e t u s e r a g en t ( ) ;

}

pub l i c func t i on r e c on f i g u r e ( $ con f i g=array ( ) ) {// de f au l t c on f i gu r a t i on opt ions$th i s−>c on f i g = array merge (

array (// l eave ’ user agent ’ blank f o r de fau l t , o therwi se s e t t h i s to// something that c l e a r l y i d e n t i f i e s your app’ user agent ’ => ’ ’ ,’ host ’ => ’ ap i . tw i t t e r . com ’ ,’method ’ => ’GET’ ,

’ consumer key ’ => ’ ’ ,’ consumer secret ’ => ’ ’ ,’ token ’ => ’ ’ ,’ s e c r e t ’ => ’ ’ ,

// OAuth2 bearer token . This should a l ready be URL encoded’ bearer ’ => ’ ’ ,

// oauth s i gn ing va r i a b l e s that are not dynamic’ oauth vers ion ’ => ’ 1 . 0 ’ ,’ oauth s ignature method ’ => ’HMAC−SHA1’ ,

// you probably don ’ t want to change any o f these cu r l va lues’ c u r l h t t p v e r s i o n ’ => CURL HTTP VERSION 1 1 ,’ cur l connect t imeout ’ => 30 ,’ cur l t imeout ’ => 10 ,

// f o r s e c u r i t y t h i s should always be s e t to 2 .’ c u r l s s l v e r i f y h o s t ’ => 2 ,// f o r s e c u r i t y t h i s should always be s e t to true .’ c u r l s s l v e r i f y p e e r ’ => true ,// f o r s e c u r i t y t h i s should always be s e t to true .’ u s e s s l ’ => true ,

// you can get the l a t e s t ca c e r t . pem from here http :// cu r l . haxx . se /ca/ cac e r t . pem// i f you ’ re g e t t i ng HTTP 0 responses , check cac e r t . pem e x i s t s and i s readab le// without i t cu r l won ’ t be ab le to c r ea t e an SSL connect ion’ c u r l c a i n f o ’ => DIR . DIRECTORY SEPARATOR . ’ c a c e r t . pem ’ ,’ cur l capath ’ => DIR ,

// in some cas e s ( very very odd ones ) the SSL ve r s i on must be s e t manually .// un l e s s you know why your are changing th i s , you should l eave i t as f a l s e// to a l low PHP to determine the value f o r t h i s s e t t i n g i t s e l f .’ c u r l s s l v e r s i o n ’ => f a l s e ,

’ c u r l f o l l ow l o c a t i o n ’ => f a l s e , // whether to f o l l ow r e d i r e c t s or not

// support f o r proxy s e r v e r s’ cur l proxy ’ => f a l s e , // r e a l l y you don ’ t want to use t h i s i f you are

us ing streaming’ curl proxyuserpwd ’ => f a l s e , // format username : password f o r proxy , i f

r equ i r ed’ cur l encod ing ’ => ’ ’ , // l eave blank f o r a l l supported formats , e l s e

use gzip , d e f l a t e , i d e n t i t y e tc

// streaming API con f i gu r a t i on

246

Page 258: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

’ i s s t r eaming ’ => f a l s e ,’ s t r eaming eo l ’ => ”\ r\n” ,’ s t r e am ing me t r i c s i n t e r va l ’ => 10 ,

// header or que ry s t r i ng . You should always use header !// t h i s i s j u s t to help me debug other deve lope r s implementat ions’ as header ’ => true ,’ f o rce nonce ’ => f a l s e , // used f o r checking s i gna tu r e s . l eave as f a l s e

f o r auto’ force t imestamp ’ => f a l s e , // used f o r checking s i gna tu r e s . l eave as f a l s e

f o r auto) ,$ con f i g

) ;}

pr i va t e func t i on r e s e t r e q u e s t s e t t i n g s ( $opt ions=array ( ) ) {$th i s−>r e q u e s t s e t t i n g s = array (

’ params ’ => array ( ) ,’ headers ’ => array ( ) ,’ with user ’ => true ,’ mult ipart ’ => f a l s e ,

) ;

i f ( ! empty ( $opt ions ) )$th i s−>r e q u e s t s e t t i n g s = array merge ( $th i s−>r e qu e s t s e t t i n g s , $opt ions ) ;

}

/∗∗∗ Sets the useragent f o r PHP to use∗ I f ’ $ th i s−>c on f i g [ ’ user agent ’ ] ’ a l r eady has a value i t i s used in s t ead o f one∗ being generated .∗∗ @return void value i s s to r ed to the con f i g array c l a s s va r i ab l e∗/

pr i va t e func t i on s e t u s e r a g en t ( ) {i f ( ! empty ( $th i s−>c on f i g [ ’ user agent ’ ] ) )

re turn ;

$ s s l = ( $th i s−>c on f i g [ ’ c u r l s s l v e r i f y h o s t ’ ] && $th i s−>c on f i g [ ’ c u r l s s l v e r i f y p e e r ’ ] &&$th i s−>c on f i g [ ’ u s e s s l ’ ] ) ? ’+ ’ : ’− ’ ;

$ua = ’tmhOAuth ’ . s e l f : : VERSION . $ s s l . ’SSL − // github . com/ thematthar r i s /tmhOAuth ’ ;$ th i s−>c on f i g [ ’ user agent ’ ] = $ua ;

}

/∗∗∗ Generates a random OAuth nonce .∗ I f ’ f o rce nonce ’ i s f a l s e a nonce w i l l be generated , o therwi se the value o f ’ $ th i s−>

c on f i g [ ’ f o rce nonce ’ ] ’ w i l l be used .∗∗ @param s t r i n g $ length how many cha ra c t e r s the nonce should be be fo r e MD5 hashing . d e f au l t

12∗ @param s t r i n g $ inc lude t ime whether to inc lude time at the beginning o f the nonce .

d e f au l t t rue∗ @return $nonce as a s t r i n g∗/

pr i va t e func t i on nonce ( $ length=12, $ inc lude t ime=true ) {i f ( $ th i s−>c on f i g [ ’ f o rce nonce ’ ] === f a l s e ) {

$p r e f i x = $ inc lude t ime ? microtime ( ) : ’ ’ ;r e turn md5( subs t r ( $p r e f i x . un iq id ( ) , 0 , $ l ength ) ) ;

} e l s e {re turn $th i s−>c on f i g [ ’ f o rce nonce ’ ] ;

}}

/∗∗∗ Generates a timestamp .∗ I f ’ force t imestamp ’ i s f a l s e a timestamp w i l l be generated , o therwi se the value o f ’

$ th i s−>c on f i g [ ’ force t imestamp ’ ] ’ w i l l be used .∗∗ @return $time as a s t r i n g∗/

pr i va t e func t i on timestamp ( ) {i f ( $ th i s−>c on f i g [ ’ force t imestamp ’ ] === f a l s e ) {

$time = time ( ) ;} e l s e {

$time = $th i s−>c on f i g [ ’ force t imestamp ’ ] ;}re turn ( s t r i n g ) $time ;

}

/∗∗∗ Encodes the s t r i n g or array passed in a way compatible with OAuth .∗ I f an array i s passed each array value w i l l w i l l be encoded .∗∗ @param mixed $data the s c a l a r or array to encode∗ @return $data encoded in a way compatible with OAuth∗/

pr i va t e func t i on sa f e encode ( $data ) {i f ( i s a r r a y ( $data ) ) {

re turn array map ( array ( $th i s , ’ sa f e encode ’ ) , $data ) ;} e l s e i f ( i s s c a l a r ( $data ) ) {

re turn s t r i r e p l a c e (array ( ’+ ’ , ’%7E’ ) ,array ( ’ ’ , ’ ˜ ’ ) ,rawurlencode ( $data )

) ;} e l s e {

re turn ’ ’ ;

247

Page 259: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}}

/∗∗∗ Decodes the s t r i n g or array from i t ’ s URL encoded form∗ I f an array i s passed each array value w i l l w i l l be decoded .∗∗ @param mixed $data the s c a l a r or array to decode∗ @return s t r i n g $data decoded from the URL encoded form∗/

pr i va t e func t i on sa f e decode ( $data ) {i f ( i s a r r a y ( $data ) ) {

re turn array map ( array ( $th i s , ’ sa f e decode ’ ) , $data ) ;} e l s e i f ( i s s c a l a r ( $data ) ) {

re turn rawurldecode ( $data ) ;} e l s e {

re turn ’ ’ ;}

}

/∗∗∗ Prepares OAuth1 s i gn ing parameters .∗∗ @return void a l l r equ i r ed OAuth parameters , s a f e l y encoded , are s to red to the c l a s s

va r i ab l e ’ $ th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] ’∗/

pr i va t e func t i on prepare oauth1 params ( ) {$de f au l t s = array (

’ oauth nonce ’ => $th i s−>nonce ( ) ,’ oauth timestamp ’ => $th i s−>timestamp ( ) ,’ oauth vers ion ’ => $th i s−>c on f i g [ ’ oauth vers ion ’ ] ,’ oauth consumer key ’ => $th i s−>c on f i g [ ’ consumer key ’ ] ,’ oauth s ignature method ’ => $th i s−>c on f i g [ ’ oauth s ignature method ’ ] ,

) ;

// inc lude the user token i f i t e x i s t si f ( $oauth token = $th i s−>token ( ) )

$d e f au l t s [ ’ oauth token ’ ] = $oauth token ;

$th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] = array ( ) ;

// s a f e l y encodefo r each ( $d e f au l t s as $k => $v ) {

$th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] [ $ th i s−>s a f e encode ( $k ) ] = $th i s−>s a f e encode ( $v) ;

}}

pr i va t e func t i on token ( ) {i f ( $ th i s−>r e q u e s t s e t t i n g s [ ’ with user ’ ] ) {

i f ( i s s e t ( $th i s−>c on f i g [ ’ token ’ ] ) && ! empty ( $th i s−>c on f i g [ ’ token ’ ] ) ) re turn $th i s−>c on f i g [ ’ token ’ ] ;

e l s e i f ( i s s e t ( $th i s−>c on f i g [ ’ user token ’ ] ) ) re turn $th i s−>c on f i g [ ’ user token ’ ] ;}re turn ’ ’ ;

}

pr i va t e func t i on s e c r e t ( ) {i f ( $ th i s−>r e q u e s t s e t t i n g s [ ’ with user ’ ] ) {

i f ( i s s e t ( $th i s−>c on f i g [ ’ s e c r e t ’ ] ) && ! empty ( $th i s−>c on f i g [ ’ s e c r e t ’ ] ) ) re turn $th i s−>c on f i g [ ’ s e c r e t ’ ] ;

e l s e i f ( i s s e t ( $th i s−>c on f i g [ ’ u s e r s e c r e t ’ ] ) ) re turn $th i s−>c on f i g [ ’ u s e r s e c r e t ’ ] ;}re turn ’ ’ ;

}

/∗∗∗ Extracts and decodes OAuth parameters from the passed s t r i n g∗∗ @param s t r i n g $body the response body from an OAuth f low method∗ @return array the response body s a f e l y decoded to an array o f key => va lues∗/

pub l i c func t i on extract params ( $body ) {$kvs = explode ( ’& ’ , $body ) ;$decoded = array ( ) ;f o r each ( $kvs as $kv ) {

$kv = explode ( ’= ’ , $kv , 2) ;$kv [ 0 ] = $th i s−>s a f e decode ( $kv [ 0 ] ) ;$kv [ 1 ] = $th i s−>s a f e decode ( $kv [ 1 ] ) ;$decoded [ $kv [ 0 ] ] = $kv [ 1 ] ;

}re turn $decoded ;

}

/∗∗∗ Prepares the HTTP method f o r use in the base s t r i n g by conver t ing i t to∗ uppercase .∗∗ @return void value i s s to r ed to the c l a s s va r i ab l e ’ $ th i s−>r e q u e s t s e t t i n g s [ ’ method ’ ] ’∗/

pr i va t e func t i on prepare method ( ) {$th i s−>r e q u e s t s e t t i n g s [ ’ method ’ ] = st r toupper ( $th i s−>r e q u e s t s e t t i n g s [ ’ method ’ ] ) ;

}

/∗∗∗ Prepares the URL f o r use in the base s t r i n g by r ipp ing i t apart and∗ r e c on s t ru c t i ng i t .∗∗ Ref : 3 . 4 . 1 . 2

248

Page 260: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗∗ @return void value i s s to r ed to the c l a s s array va r i ab l e ’ $ th i s−>r e q u e s t s e t t i n g s [ ’ ur l ’ ] ’∗/

pr i va t e func t i on p r epa r e u r l ( ) {$part s = pa r s e u r l ( $th i s−>r e q u e s t s e t t i n g s [ ’ ur l ’ ] ) ;

$port = i s s e t ( $parts [ ’ port ’ ] ) ? $parts [ ’ port ’ ] : f a l s e ;$scheme = $parts [ ’ scheme ’ ] ;$host = $parts [ ’ host ’ ] ;$path = i s s e t ( $parts [ ’ path ’ ] ) ? $parts [ ’ path ’ ] : f a l s e ;

$port or $port = ( $scheme == ’ https ’ ) ? ’443 ’ : ’ 8 0 ’ ;

i f ( ( $scheme == ’ https ’ && $port != ’443 ’ ) | | ( $scheme == ’ http ’ && $port != ’80 ’ ) ) {$host = ” $host : $port ” ;

}

// the scheme and host MUST be lowercase$th i s−>r e q u e s t s e t t i n g s [ ’ ur l ’ ] = s t r t o l owe r (” $scheme :// $host ”) ;// but not the path$th i s−>r e q u e s t s e t t i n g s [ ’ ur l ’ ] .= $path ;

}

/∗∗∗ I f the reques t uses mult ipart , and the parameter isn ’ t a f i l e path , prepend a space∗ otherwi se return the o r i g i n a l value . we chose a space here as tw i t t e r whitespace tr ims

from∗ the beginning o f the tweet . we don ’ t use \0 here because i t ’ s the charac t e r f o r s t r i n g∗ te rminat ion .∗∗ @param the parameter value∗ @return s t r i n g the o r i g i n a l or modi f ied s t r ing , depending on the reques t and the input

parameter∗/

pr i va t e func t i on mul t ipa r t e s cape ( $value ) {i f ( ! $ th i s−>r e q u e s t s e t t i n g s [ ’ mult ipart ’ ] | | s t rpo s ( $value , ’@’ ) !== 0)

return $value ;

// see i f the parameter i s a f i l e .// we s p l i t on the semi−co lon as i t ’ s the d e l im i t e r used on media uploads// f o r f i e l d s with semi−co lons t h i s w i l l r e turn the o r i g i n a l s t r i n gl i s t ( $ f i l e ) = explode ( ’ ; ’ , subs t r ( $value , 1) , 2) ;i f ( f i l e e x i s t s ( $ f i l e ) )

re turn $value ;

re turn ” $value ” ;}

/∗∗∗ Prepares a l l parameters f o r the base s t r i n g and reques t .∗ Mult ipart parameters are ignored as they are not de f ined in the s p e c i f i c a t i o n ,∗ a l l other types o f parameter are encoded f o r compat i b i l i t y with OAuth .∗∗ @param array $params the parameters f o r the reques t∗ @return void prepared va lues are s to r ed in the c l a s s array va r i ab l e ’ $ th i s−>

r e qu e s t s e t t i n g s ’∗/

pr i va t e func t i on prepare params ( ) {$doing oauth1 = f a l s e ;$ th i s−>r e q u e s t s e t t i n g s [ ’ prepared params ’ ] = array ( ) ;$prepared = &$th i s−>r e q u e s t s e t t i n g s [ ’ prepared params ’ ] ;$p r epa r ed pa i r s = array ( ) ;$p r epared pa i r s w i th oauth = array ( ) ;

i f ( i s s e t ( $th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] ) ) {$oauth1 = &$th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] ;$doing oauth1 = true ;$params = array merge ( $oauth1 , $th i s−>r e q u e s t s e t t i n g s [ ’ params ’ ] ) ;

// Remove oauth s i gnature i f p re sent// Ref : Spec : 9 . 1 . 1 (”The oauth s i gnature parameter MUST be excluded . ” )unset ( $params [ ’ oauth s ignature ’ ] ) ;

// empty the oauth1 array . we r e s e t these va lues l a t e r in t h i s method$oauth1 = array ( ) ;

} e l s e {$params = $th i s−>r e q u e s t s e t t i n g s [ ’ params ’ ] ;

}

// Parameters are so r t ed by name , us ing l e x i c o g r a ph i c a l byte value orde r ing .// Ref : Spec : 9 . 1 . 1 (1 )uksort ( $params , ’ strcmp ’ ) ;

// s e t t h i s now so we ’ re not doing i t on every parameter$ 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 ( ’ Cur lFi l e ’ , f a l s e ) ;

// encode params un l e s s we ’ re doing mult ipartf o r each ( $params as $k => $v ) {

$k = $th i s−>r e q u e s t s e t t i n g s [ ’ mult ipart ’ ] ? $k : $th i s−>s a f e encode ( $k ) ;

i f ( i s a r r a y ( $v ) )$v = implode ( ’ , ’ , $v ) ;

// we don ’ t need to do the mult ipart escap ing i f we support c u r l f i l ei f ( $ s u p p o r t s c u r l f i l e && ( $v i n s t an c e o f Cur lF i l e ) ) {

// l eave $v a lone} e l s e i f ( $ th i s−>r e q u e s t s e t t i n g s [ ’ mult ipart ’ ] ) {

$v = $th i s−>mul t ipa r t e s cape ( $v ) ;

249

Page 261: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

} e l s e {$v = $th i s−>s a f e encode ( $v ) ;

}

// s p l i t parameters f o r the ba s e s t r i n g and autho r i z a t i on header , and r e c r e a t e the oauth1array

i f ( $doing oauth1 ) {// i f we ’ re doing mult ipart , only s t o r e the oauth ∗ params , i gnore the use r s r eques t

paramsi f ( ( s t rpo s ( $k , ’ oauth ’ ) === 0) | | ! $ th i s−>r e q u e s t s e t t i n g s [ ’ mult ipart ’ ] )

$p repared pa i r s w i th oauth [ ] = ”{$k}={$v }” ;

i f ( s t rpo s ( $k , ’ oauth ’ ) === 0) {$oauth1 [ $k ] = $v ;cont inue ;

}}$prepared [ $k ] = $v ;

i f ( ! $ th i s−>r e q u e s t s e t t i n g s [ ’ mult ipart ’ ] )$p r epa r ed pa i r s [ ] = ”{$k}={$v }” ;

}

i f ( $doing oauth1 ) {$th i s−>r e q u e s t s e t t i n g s [ ’ basestr ing params ’ ] = implode ( ’& ’ , $p repared pa i r s w i th oauth ) ;

}

// setup params f o r GET/POST/PUT method handl ingi f ( ! empty ( $prepared ) ) {

$content = implode ( ’& ’ , $p r epa r ed pa i r s ) ;

switch ( $th i s−>r e q u e s t s e t t i n g s [ ’ method ’ ] ) {case ’PUT’ :

// f a l l through to POST as PUT should be t r ea t ed the samecase ’POST’ :

$th 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 ’ ] = $th i s−>r e q u e s t s e t t i n g s [ ’ mult ipart ’ ] ?$prepared : $content ;

break ;d e f au l t :

$ th i s−>r e q u e s t s e t t i n g s [ ’ queryst r ing ’ ] = $content ;break ;

}}

}

/∗∗∗ Prepares the OAuth s i gn ing key∗∗ @return void prepared s i gn ing key i s s to red in the c l a s s va r i ab l e ’ s i gn ing key ’∗/

pr i va t e func t i on p r epa r e s i gn ing key ( ) {$ l e f t = $th i s−>s a f e encode ( $th i s−>c on f i g [ ’ consumer secret ’ ] ) ;$ r i gh t = $th i s−>s a f e encode ( $th i s−>s e c r e t ( ) ) ;$ th i s−>r e q u e s t s e t t i n g s [ ’ s i gn ing key ’ ] = $ l e f t . ’& ’ . $ r i gh t ;

}

/∗∗∗ Prepare the base s t r i n g .∗ Ref : Spec : 9 . 1 . 3 (” Concatenate Request Elements ”)∗∗ @return void prepared base s t r i n g i s s to r ed in the c l a s s va r i ab l e ’ ba s e s t r i ng ’∗/

pr i va t e func t i on p r epa r e ba s e s t r i n g ( ) {$ur l = $th i s−>r e q u e s t s e t t i n g s [ ’ ur l ’ ] ;

# i f the host header i s s e t we need to r ewr i t e the ba s e s t r i n g to use# that , i n s t ead o f the reques t host . o therwi se the s i gna tu r e won ’ t match# on the s e r v e r s i d ei f ( ! empty ( $th i s−>r e q u e s t s e t t i n g s [ ’ headers ’ ] [ ’ Host ’ ] ) ) {

$ur l = s t r i r e p l a c e ($th i s−>c on f i g [ ’ host ’ ] ,$ th i s−>r e q u e s t s e t t i n g s [ ’ headers ’ ] [ ’ Host ’ ] ,$u r l

) ;}

$base = array ($th i s−>r e q u e s t s e t t i n g s [ ’ method ’ ] ,$ur l ,$ th i s−>r e q u e s t s e t t i n g s [ ’ basestr ing params ’ ]

) ;$ th i s−>r e q u e s t s e t t i n g s [ ’ ba se s t r ing ’ ] = implode ( ’& ’ , $ th i s−>s a f e encode ( $base ) ) ;

}

/∗∗∗ Signs the OAuth 1 reques t∗∗ @return void oauth s i gnature i s added to the parameters in the c l a s s array va r i ab l e ’

$ th i s−>r e qu e s t s e t t i n g s ’∗/

pr i va t e func t i on pr epa r e oauth s i gna tu r e ( ) {$th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] [ ’ oauth s ignature ’ ] = $th i s−>s a f e encode (

base64 encode (hash hmac (

’ sha1 ’ , $ th i s−>r e q u e s t s e t t i n g s [ ’ ba se s t r ing ’ ] , $ th i s−>r e q u e s t s e t t i n g s [ ’ s i gn ing key’ ] , t rue

) ) ) ;}

250

Page 262: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

/∗∗∗ Prepares the Author izat ion header∗∗ @return void prepared au tho r i z a t i on header i s s to r ed in the c l a s s va r i ab l e headers [ ’

Author izat ion ’ ]∗/

pr i va t e func t i on prepare auth header ( ) {i f ( ! $ th i s−>c on f i g [ ’ as header ’ ] )

re turn ;

// oauth1i f ( i s s e t ( $th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] ) ) {

// so r t again as oauth s i gnature was added post param preparat ionuksort ( $th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] , ’ strcmp ’ ) ;$encoded quoted pa i r s = array ( ) ;f o r each ( $th i s−>r e q u e s t s e t t i n g s [ ’ oauth1 params ’ ] as $k => $v ) {

$encoded quoted pa i r s [ ] = ”{$k}=\”{$v }\””;}$header = ’OAuth ’ . implode ( ’ , ’ , $encoded quoted pa i r s ) ;

} e l s e i f ( ! empty ( $th i s−>c on f i g [ ’ bearer ’ ] ) ) {$header = ’ Bearer ’ . $ th i s−>c on f i g [ ’ bearer ’ ] ;

}

i f ( i s s e t ( $header ) )$th i s−>r e q u e s t s e t t i n g s [ ’ headers ’ ] [ ’ Author izat ion ’ ] = $header ;

}

/∗∗∗ Create the bearer token f o r OAuth2 r eque s t s from the consumer key and consumer secre t .∗∗ @return s t r i n g the bearer token∗/

pub l i c func t i on b e a r e r t o k en c r e d en t i a l s ( ) {$ c r e d e n t i a l s = implode ( ’ : ’ , array (

$th i s−>s a f e encode ( $th i s−>c on f i g [ ’ consumer key ’ ] ) ,$ th i s−>s a f e encode ( $th i s−>c on f i g [ ’ consumer secret ’ ] )

) ) ;r e turn base64 encode ( $ c r e d en t i a l s ) ;

}

/∗∗∗ Make an HTTP reques t us ing t h i s l i b r a r y . This method doesn ’ t re turn anything .∗ Ins tead the response should be in spec t ed d i r e c t l y .∗∗ @param s t r i n g $method the HTTP method being used . e . g . POST, GET, HEAD etc∗ @param s t r i n g $ur l the reques t URL without query s t r i n g parameters∗ @param array $params the reques t parameters as an array o f key=value pa i r s . Defau l t empty

array∗ @param s t r i n g $useauth whether to use authent i ca t i on when making the reques t . Defau l t

t rue∗ @param s t r i n g $mult ipart whether t h i s r eques t conta ins mult ipart data . Defau l t f a l s e∗ @param array $headers any custom headers to send with the reques t . Defau l t empty array∗ @return in t the http response code f o r the reques t . 0 i s returned i f a connect ion could

not be made∗/

pub l i c func t i on reques t ( $method , $url , $params=array ( ) , $useauth=true , $mult ipart=f a l s e ,$headers=array ( ) ) {

$opt ions = array (’method ’ => $method ,’ ur l ’ => $url ,’ params ’ => $params ,’ with user ’ => true ,’ mult ipart ’ => $mult ipart ,’ headers ’ => $headers

) ;$opt ions = array merge ( $th i s−>d e f au l t o p t i o n s ( ) , $opt ions ) ;

i f ( $useauth ) {re turn $th i s−>u s e r r e qu e s t ( $opt ions ) ;

} e l s e {re turn $th i s−>unauthent i ca t ed reques t ( $opt ions ) ;

}}

pub l i c func t i on appon ly request ( $opt ions=array ( ) ) {$opt ions = array merge ( $th i s−>d e f au l t o p t i o n s ( ) , $opt ions , array (

’ with user ’ => f a l s e ,) ) ;$ th i s−>r e s e t r e q u e s t s e t t i n g s ( $opt ions ) ;i f ( $opt ions [ ’ without bearer ’ ] ) {

re turn $th i s−>oauth1 request ( ) ;} e l s e {

$th i s−>prepare method ( ) ;$ th i s−>p r epa r e u r l ( ) ;$ th i s−>prepare params ( ) ;$ th i s−>prepare auth header ( ) ;r e turn $th i s−>c u r l i t ( ) ;

}}

pub l i c func t i on u s e r r e qu e s t ( $opt ions=array ( ) ) {$opt ions = array merge ( $th i s−>d e f au l t o p t i o n s ( ) , $opt ions , array (

’ with user ’ => true ,) ) ;$ th i s−>r e s e t r e q u e s t s e t t i n g s ( $opt ions ) ;r e turn $th i s−>oauth1 request ( ) ;

}

pub l i c func t i on unauthent i ca t ed reques t ( $opt ions=array ( ) ) {

251

Page 263: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$opt ions = array merge ( $th i s−>d e f au l t o p t i o n s ( ) , $opt ions , array (’ with user ’ => f a l s e ,

) ) ;$ th i s−>r e s e t r e q u e s t s e t t i n g s ( $opt ions ) ;$ th i s−>prepare method ( ) ;$ th i s−>p r epa r e u r l ( ) ;$ th i s−>prepare params ( ) ;r e turn $th i s−>c u r l i t ( ) ;

}

/∗∗∗ Signs the reques t and adds the OAuth s i gna tu r e . This runs a l l the reques t∗ parameter preparat ion methods .∗∗ @param s t r i n g $method the HTTP method being used . e . g . POST, GET, HEAD etc∗ @param s t r i n g $ur l the reques t URL without query s t r i n g parameters∗ @param array $params the reques t parameters as an array o f key=value pa i r s∗ @param boolean $wi th use r whether to inc lude the user c r e d e n t i a l s when making the reques t

.∗ @return void∗/

pr i va t e func t i on oauth1 request ( ) {$th i s−>prepare oauth1 params ( ) ;$ th i s−>prepare method ( ) ;$ th i s−>p r epa r e u r l ( ) ;$ th i s−>prepare params ( ) ;$ th i s−>p r epa r e ba s e s t r i n g ( ) ;$ th i s−>pr epa r e s i gn ing key ( ) ;$ th i s−>prepa r e oauth s i gna tu r e ( ) ;$ th i s−>prepare auth header ( ) ;r e turn $th i s−>c u r l i t ( ) ;

}

pr i va t e func t i on d e f a u l t o p t i o n s ( ) {re turn array (

’method ’ => ’GET’ ,’ params ’ => array ( ) ,’ with user ’ => true ,’ mult ipart ’ => f a l s e ,’ headers ’ => array ( ) ,’ wi thout bearer ’ => f a l s e ,

) ;}

/∗∗∗ Make a long p o l l HTTP reques t us ing t h i s l i b r a r y . This method i s∗ d i f f e r e n t to the other r eques t methods as i t i sn ’ t supposed to d i s connec t∗∗ Using t h i s method expects a ca l l ba ck which w i l l r e c e i v e the streaming∗ r e sponse s .∗∗ @param s t r i n g $method the HTTP method being used . e . g . POST, GET, HEAD etc∗ @param s t r i n g $ur l the reques t URL without query s t r i n g parameters∗ @param array $params the reques t parameters as an array o f key=value pa i r s∗ @param s t r i n g $ca l l back the ca l l ba ck func t i on to stream the bu f f e r to .∗ @return void∗/

pub l i c func t i on s t r eaming reque s t ( $method , $url , $params=array ( ) , $ ca l l back = ’ ’) {i f ( ! empty ( $ca l l back ) ) {

i f ( ! i s c a l l a b l e ( $ ca l l back ) ) {re turn f a l s e ;

}$th i s−>c on f i g [ ’ s t r eaming ca l lback ’ ] = $ca l l back ;

}$th i s−>metr i c s [ ’ s t a r t ’ ] = time ( ) ;$ th i s−>metr i c s [ ’ i n t e r v a l s t a r t ’ ] = $th i s−>metr i c s [ ’ s ta r t ’ ] ;$ th i s−>metr i c s [ ’ messages ’ ] = 0 ;$th i s−>metr i c s [ ’ l a s t message s ’ ] = 0 ;$th i s−>metr i c s [ ’ bytes ’ ] = 0 ;$th i s−>metr i c s [ ’ l a s t by t e s ’ ] = 0 ;$th i s−>c on f i g [ ’ i s s t r eaming ’ ] = true ;$th i s−>r eques t ( $method , $ur l , $params ) ;

}

/∗∗∗ Handles the updating o f the cur rent Streaming API metr i c s .∗∗ @return array the metr i c s f o r the streaming api connect ion∗/

pr i va t e func t i on update metr i c s ( ) {$now = time ( ) ;i f ( ( $th i s−>metr i c s [ ’ i n t e r v a l s t a r t ’ ] + $th i s−>c on f i g [ ’ s t r e am ing me t r i c s i n t e r va l ’ ] ) >

$now)return nu l l ;

$ th i s−>metr i c s [ ’mps ’ ] = round ( ( $th i s−>metr i c s [ ’ messages ’ ] − $th i s−>metr i c s [ ’ l a s t message s’ ] ) / $th i s−>c on f i g [ ’ s t r e am ing me t r i c s i n t e r va l ’ ] , 2) ;

$ th i s−>metr i c s [ ’ bps ’ ] = round ( ( $th i s−>metr i c s [ ’ bytes ’ ] − $th i s−>metr i c s [ ’ l a s t by t e s ’ ] ) /$th i s−>c on f i g [ ’ s t r e am ing me t r i c s i n t e r va l ’ ] , 2) ;

$ th i s−>metr i c s [ ’ l a s t by t e s ’ ] = $th i s−>metr i c s [ ’ bytes ’ ] ;$ th i s−>metr i c s [ ’ l a s t message s ’ ] = $th i s−>metr i c s [ ’ messages ’ ] ;$ th i s−>metr i c s [ ’ i n t e r v a l s t a r t ’ ] = $now ;return $th i s−>metr i c s ;

}

/∗∗∗ Ut i l i t y func t i on to c r ea t e the reques t URL in the requested format .∗ I f a f u l l y−q u a l i f i e d URI i s provided , i t w i l l be returned .

252

Page 264: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

∗ Any multi−s l a s h e s ( except f o r the p ro toco l ) w i l l be r ep laced with a s i n g l e s l a sh .∗∗∗ @param s t r i n g $reques t the API method without extens ion∗ @param s t r i n g $extens ion the format o f the response . Defau l t j son . Set to an empty s t r i n g

to exc lude the format∗ @return s t r i n g the concatenat ion o f the host , API vers ion , API method and format , or

$reques t i f i t beg ins with http∗/

pub l i c func t i on u r l ( $request , $extens ion=’ json ’ ) {// remove multi−s l a s h e s$reques t = pr eg r ep l a c e ( ’ $ ( [ ˆ : ] ) //+$ ’ , ’ $1 / ’ , $ reques t ) ;

i f ( s t r i p o s ( $request , ’ http ’ ) === 0 | | s t r i p o s ( $request , ’ // ’ ) === 0) {re turn $reques t ;

}

$extens ion = s t r l e n ( $extens ion ) > 0 ? ” . $extens ion ” : ’ ’ ;$proto = $th i s−>c on f i g [ ’ u s e s s l ’ ] ? ’ https : / ’ : ’ http : / ’ ;

// trim t r a i l i n g s l a sh$reques t = l t r im ( $request , ’ / ’ ) ;

$pos = s t r l e n ( $reques t ) − s t r l e n ( $extens ion ) ;i f ( subs t r ( $request , $pos ) === $extens ion )

$reques t = sub s t r r e p l a c e ( $request , ’ ’ , $pos ) ;

r e turn implode ( ’ / ’ , array ($proto ,$th i s−>c on f i g [ ’ host ’ ] ,$ reques t . $extens ion

) ) ;}

/∗∗∗ Publ ic a c c e s s to the p r i va t e s a f e decode/ encode methods∗∗ @param s t r i n g $text the text to transform∗ @param s t r i n g $mode the t rans fo rmat ion mode . e i t h e r encode or decode∗ @return s t r i n g $text transformed by the given $mode∗/

pub l i c func t i on transformText ( $text , $mode=’encode ’ ) {re turn $th i s−>{”safe $mode ”}( $text ) ;

}

/∗∗∗ Ut i l i t y func t i on to parse the returned cu r l headers and s t o r e them in the∗ c l a s s array va r i ab l e .∗∗ @param ob j e c t $ch cu r l handle∗ @param s t r i n g $header the response headers∗ @return s t r i n g the length o f the header∗/

pr i va t e func t i on cur lHeader ( $ch , $header ) {$th i s−>re sponse [ ’ raw ’ ] .= $header ;

l i s t ( $key , $value ) = array pad ( explode ( ’ : ’ , $header , 2) , 2 , nu l l ) ;

$key = trim ( $key ) ;$value = trim ( $value ) ;

i f ( ! i s s e t ( $th i s−>re sponse [ ’ headers ’ ] [ $key ] ) ) {$th i s−>re sponse [ ’ headers ’ ] [ $key ] = $value ;

} e l s e {i f ( ! i s a r r a y ( $th i s−>re sponse [ ’ headers ’ ] [ $key ] ) ) {

$th i s−>re sponse [ ’ headers ’ ] [ $key ] = array ( $th i s−>re sponse [ ’ headers ’ ] [ $key ] ) ;}$th i s−>re sponse [ ’ headers ’ ] [ $key ] [ ] = $value ;

}

re turn s t r l e n ( $header ) ;}

/∗∗∗ Ut i l i t y func t i on to parse the returned cu r l bu f f e r and s t o r e them un t i l∗ an EOL i s found . The bu f f e r f o r cu r l i s an undef ined s i z e so we need∗ to c o l l e c t the content un t i l an EOL i s found .∗∗ This func t i on c a l l s the p r ev i ou s l y de f ined streaming ca l l ba ck method .∗∗ @param ob j e c t $ch cu r l handle∗ @param s t r i n g $data the cur rent cu r l bu f f e r∗ @return in t the l ength o f the data s t r i n g proces sed in t h i s func t i on∗/

pr i va t e func t i on cur lWrite ( $ch , $data ) {$ l = s t r l e n ( $data ) ;i f ( s t rpo s ( $data , $th i s−>c on f i g [ ’ s t r eaming eo l ’ ] ) === f a l s e ) {

$th i s−>bu f f e r .= $data ;re turn $ l ;

}

$bu f f e r ed = explode ( $th i s−>c on f i g [ ’ s t r eaming eo l ’ ] , $data ) ;$content = $th i s−>bu f f e r . $bu f f e r ed [ 0 ] ;

$ th i s−>metr i c s [ ’ messages ’ ]++;$th i s−>metr i c s [ ’ bytes ’ ] += s t r l e n ( $content ) ;

i f ( ! i s c a l l a b l e ( $th i s−>c on f i g [ ’ s t r eaming ca l lback ’ ] ) )re turn 0 ;

253

Page 265: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$metr i c s = $th i s−>update metr i c s ( ) ;$stop = c a l l u s e r f u n c (

$th i s−>c on f i g [ ’ s t r eaming ca l lback ’ ] ,$content ,s t r l e n ( $content ) ,$metr i c s

) ;$ th i s−>bu f f e r = $bu f f e r ed [ 1 ] ;i f ( $stop )

return 0 ;

re turn $ l ;}

/∗∗∗ Makes a cu r l r eques t . Takes no parameters as a l l should have been prepared∗ by the reques t method∗∗ the response data i s s to r ed in the c l a s s va r i ab l e ’ response ’∗∗ @return in t the http response code f o r the reques t . 0 i s returned i f a connect ion could

not be made∗/

pr i va t e func t i on c u r l i t ( ) {$th i s−>re sponse = array (

’ raw ’ => ’ ’) ;

// con f i gu r e cu r l$c = c u r l i n i t ( ) ;

i f ( $ th i s−>r e q u e s t s e t t i n g s [ ’ method ’ ] == ’GET’ && i s s e t ( $th i s−>r e q u e s t s e t t i n g s [ ’querys t r ing ’ ] ) ) {

$th i s−>r e q u e s t s e t t i n g s [ ’ ur l ’ ] = $th i s−>r e q u e s t s e t t i n g s [ ’ ur l ’ ] . ’ ? ’ . $ th i s−>r e q u e s t s e t t i n g s [ ’ queryst r ing ’ ] ;

} e l s e i f ( $ th i s−>r e q u e s t s e t t i n g s [ ’ method ’ ] == ’POST’ | | $th 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 ( $th 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 = $th 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 ’ ] ;

c u r l s e t o p t ( $c , CURLOPT POSTFIELDS, $ p o s t f i e l d s ) ;}

c u r l s e t o p t ( $c , CURLOPTCUSTOMREQUEST, $th 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 , array (CURLOPT HTTP VERSION => $th i s−>c on f i g [ ’ c u r l h t t p v e r s i o n ’ ] ,CURLOPT USERAGENT => $th i s−>c on f i g [ ’ user agent ’ ] ,CURLOPTCONNECTTIMEOUT => $th i s−>c on f i g [ ’ cur l connect t imeout ’ ] ,CURLOPT TIMEOUT => $th i s−>c on f i g [ ’ cur l t imeout ’ ] ,CURLOPTRETURNTRANSFER => true ,CURLOPT SSL VERIFYPEER => $th i s−>c on f i g [ ’ c u r l s s l v e r i f y p e e r ’ ] ,CURLOPT SSL VERIFYHOST => $th i s−>c on f i g [ ’ c u r l s s l v e r i f y h o s t ’ ] ,

CURLOPTFOLLOWLOCATION => $th i s−>c on f i g [ ’ c u r l f o l l ow l o c a t i o n ’ ] ,CURLOPTPROXY => $th i s−>c on f i g [ ’ cur l proxy ’ ] ,CURLOPT ENCODING => $th i s−>c on f i g [ ’ cur l encod ing ’ ] ,CURLOPT URL => $th i s−>r e q u e s t s e t t i n g s [ ’ ur l ’ ] ,// proce s s the headersCURLOPT HEADERFUNCTION => array ( $th i s , ’ curlHeader ’ ) ,CURLOPTHEADER => f a l s e ,CURLINFO HEADER OUT => true ,

) ) ;

i f ( $ th i s−>c on 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, $th i s−>c on f i g [ ’ c u r l c a i n f o ’ ] ) ;

i f ( $ th i s−>c on f i g [ ’ cur l capath ’ ] !== f a l s e )c u r l s e t o p t ( $c , CURLOPT CAPATH, $th i s−>c on f i g [ ’ cur l capath ’ ] ) ;

i f ( $ th i s−>c on f i g [ ’ cur l proxyuserpwd ’ ] !== f a l s e )c u r l s e t o p t ( $c , CURLOPTPROXYUSERPWD, $th i s−>c on f i g [ ’ cur l proxyuserpwd ’ ] ) ;

i f ( $ th i s−>c on 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, $th i s−>c on f i g [ ’ c u r l s s l v e r s i o n ’ ] ) ;

i f ( $ th i s−>c on f i g [ ’ i s s t r eaming ’ ] ) {// proce s s the body$th i s−>re sponse [ ’ content−length ’ ] = 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 ( $th i s , ’ cur lWrite ’ ) ) ;

}

i f ( ! empty ( $th i s−>r e q u e s t s e t t i n g s [ ’ headers ’ ] ) ) {f o r each ( $th i s−>r e q u e s t s e t t i n g s [ ’ headers ’ ] as $k => $v ) {

$headers [ ] = trim ( $k . ’ : ’ . $v ) ;}c u r l s e t o p t ( $c , CURLOPTHTTPHEADER, $headers ) ;

}

i f ( i s s e t ( $th i s−>c on f i g [ ’ block ’ ] ) && ( true === $th i s−>c on f i g [ ’ block ’ ] ) )re turn 0 ;

// do i t !$response = cu r l e x e c ( $c ) ;$code = 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

Page 266: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$e r r o r = c u r l e r r o r ( $c ) ;$errno = cu r l e r r n o ( $c ) ;c u r l c l o s e ( $c ) ;

// s t o r e the response$th i s−>re sponse [ ’ code ’ ] = $code ;$th i s−>re sponse [ ’ response ’ ] = $response ;$th i s−>re sponse [ ’ in fo ’ ] = $ in f o ;$th i s−>re sponse [ ’ e r ror ’ ] = $e r r o r ;$ th i s−>re sponse [ ’ errno ’ ] = $errno ;

i f ( ! i s s e t ( $th i s−>re sponse [ ’ raw ’ ] ) ) {$th i s−>re sponse [ ’ raw ’ ] = ’ ’ ;

}$th i s−>re sponse [ ’ raw ’ ] .= $response ;

re turn $code ;}

}

<?phpi f ( ! de f ined ( ’BASEPATH’ ) )

e x i t ( ’No d i r e c t s c r i p t a c c e s s al lowed ’ ) ;

/∗∗∗ CodeIgn i ter Twitter∗∗ A CodeIgn i ter l i b r a r y to i n t e r a c t with Api Twitter .∗ Or ig ina l author : e l l i o t h augh i n∗∗ @package CodeIgn i ter∗ @category L i b r a r i e s∗ @author Marcos Sanz∗ @link https :// github . com/marsanla / code i gn i t e r−tw i t t e r∗ @l i cense http ://www. opensource . org / l i c e n s e s /mit−l i c e n s e . html∗/

c l a s s tweet {

pr i va t e $ oauth = NULL;

func t i on c on s t r u c t ( ) {$ th i s −> oauth = new tweetOauth ( ) ;

}

f unc t i on c a l l ( $method , $args ) {i f ( method ex i s t s ( $th i s , $method ) ) {

re turn c a l l u s e r f u n c a r r a y ( array ( $th i s , $method ) , $args ) ;}

re turn c a l l u s e r f u n c a r r a y ( array ( $ th i s −> oauth , $method ) , $args ) ;}

f unc t i on l ogg ed in ( ) {re turn $ th i s −> oauth −> l oggedIn ( ) ;

}

f unc t i on get header ( ) {re turn $ th i s −> oauth −> getHeader ( ) ;

}

f unc t i on s e t c a l l b a c k ( $ur l ) {$ th i s −> oauth −> s e tCa l lback ( $ur l ) ;

}

f unc t i on l o g i n ( $ s i g n i n tw i t t e r = f a l s e ) {re turn $ th i s −> oauth −> l o g i n ( $ s i g n i n tw i t t e r ) ;

}

f unc t i on logout ( ) {re turn $ th i s −> oauth −> l ogout ( ) ;

}

f unc t i on ge t tokens ( ) {$tokens = array (

’ oauth token ’ => $ th i s −> oauth −> getAccessKey ( ) ,’ oauth token sec r e t ’ => $ th i s −> oauth −> ge tAcce s sSec r e t ( )

) ;

r e turn $tokens ;}

f unc t i on s e t t ok en s ( $tokens ) {re turn $ th i s −> oauth −> setAccessTokens ( $tokens ) ;

}

}

c l a s s tweetException extends Exception {

f unc t i on c on s t r u c t ( $ s t r i n g ) {parent : : c o n s t r u c t ( $ s t r i n g ) ;

}

pub l i c func t i on t o S t r i n g ( ) {re turn ” except ion ’” . CLASS . ” ’ with message ’” . $ th i s −> getMessage ( )

. ” ’ in ” . $ th i s −> g e tF i l e ( ) . ” : ” . $ th i s −> getLine ( ) . ”\nStack t rac e:\n” . $ th i s −> getTraceAsStr ing ( ) ;

255

Page 267: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}

}

c l a s s tweetConnection {

// Allow multi−thread ing .

p r i va t e $ mch = NULL;p r i va t e $ p r op e r t i e s = array ( ) ;

pub l i c $header = NULL;

func t i on c on s t r u c t ( ) {$ th i s −> mch = c u r l mu 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,’ length ’ => CURLINFO CONTENT LENGTH DOWNLOAD,’ type ’ => CURLINFO CONTENT TYPE

) ;}

pr i va t e func t i on in i tConnec t i on ( $ur l ) {$ th i s −> ch = c u r l i n i t ( $ur l ) ;c u r l s e t o p t ( $ th i s −> ch , CURLOPTRETURNTRANSFER, TRUE) ;c u r l s e t o p t ( $ th i s −> ch , CURLOPT VERBOSE, TRUE) ;c u r l s e t o p t ( $ th i s −> ch , CURLOPT HEADER, TRUE) ;

}

pub l i c func t i on get ( $ur l , $params ) {i f ( count ( $params [ ’ request ’ ] ) > 0) {

$ur l .= ’ ? ’ ;

f o r each ( $params [ ’ request ’ ] as $k => $v ) {$k = s t r i r e p l a c e ( array ( ’+ ’ , ’%7E’ ) , array ( ’ ’ , ’ ˜ ’ ) ,

rawurlencode ( $k ) ) ;$v = s t r i r e p l a c e ( array ( ’+ ’ , ’%7E’ ) , array ( ’ ’ , ’ ˜ ’ ) ,

rawurlencode ( $v ) ) ;$ur l .= ”{$k}={$v}&”;

}

$ur l = subs t r ( $ur l , 0 , −1) ;}

$ th i s −> i n i tConnec t i on ( $ur l ) ;$response = $ th i s −> addCurl ( $ur l , $params ) ;

re turn $response ;}

pub l i c func t i on post ( $url , $params ) {$post = ’ ’ ;

f o r each ( $params [ ’ request ’ ] as $k => $v ) {$k = s t r i r e p l a c e ( array ( ’+ ’ , ’%7E’ ) , array ( ’ ’ , ’ ˜ ’ ) , rawurlencode ( $k )

) ;$v = s t r i r e p l a c e ( array ( ’+ ’ , ’%7E’ ) , array ( ’ ’ , ’ ˜ ’ ) , rawurlencode ( $v )

) ;$post .= ”{$k}={$v}&”;

}

$post = subst r ( $post , 0 , −1) ;

$ th i s −> i n i tConnec t i on ( $url , $params ) ;c u r l s e t o p t ( $ th i s −> ch , CURLOPT POST, 1) ;c u r l s e t o p t ( $ th i s −> ch , CURLOPT POSTFIELDS, $post ) ;

$response = $ th i s −> addCurl ( $ur l , $params ) ;

re turn $response ;}

pr i va t e func t i on addOauthHeaders(&$ch , $ur l , $oauthHeaders ) {$ h = array (

’ Expect : ’ ,’ Connection : Keep−Alive ’ ,’Cache−Control : no−cache ’

) ;

i f ( i s s e t ($ SERVER[ ’HTTP USER AGENT’ ] ) ) {array push ( $ h , ’ User−Agent : ’ . $ SERVER[ ’HTTP USER AGENT’ ] ) ;

}

$ur lPar t s = pa r s e u r l ( $ur l ) ;$oauth = ’ Author izat ion : OAuth realm=”’ . $ur lPar t s [ ’ path ’ ] . ’ ” , ’ ;

f o r each ( $oauthHeaders as $name => $value ) {$oauth .= ”{$name}=\”{$value }\” ,” ;

}

// Addit iona l headers$ h [ ] = subs t r ( $oauth , 0 , −1) ;

c u r l s e t o p t ( $ch , CURLOPTHTTPHEADER, $ h ) ;}

pr i va t e func t i on addCurl ( $ur l , $params = array ( ) ) {

256

Page 268: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

i f ( ! empty ( $params [ ’ oauth ’ ] ) ) {$ th i s −> addOauthHeaders ( $ th i s −> ch , $ur l , $params [ ’ oauth ’ ] ) ;

}

$ch = $ th i s −> ch ;

$key = ( s t r i n g ) $ch ;$ th i s −> r e qu e s t s [ $key ] = $ch ;

$response = cur l mu l t i add hand l e ( $ th i s −> mch , $ch ) ;

i f ( $response === CURLMOK | | $response === CURLM CALL MULTI PERFORM) {do {

$mch = cu r l mu l t i e x e c ( $ th i s −> mch , $ac t i v e ) ;} whi le ( $mch === CURLM CALL MULTI PERFORM ) ;

return $ th i s −> getResponse ( $key ) ;} e l s e {

re turn $response ;}

}

pr i va t e func t i on getResponse ( $key = NULL) {i f ( $key == NULL)

return FALSE;

i f ( i s s e t ( $ th i s −> r e spon s e s [ $key ] ) ) {re turn $ th i s −> r e spon s e s [ $key ] ;

}

$running = NULL;

do {$response = cu r l mu l t i e x e c ( $ th i s −> mch , $ runn ing cur l ) ;

i f ( $running !== NULL && $runn ing cur l != $running ) {$ th i s −> setResponse ( $key ) ;

i f ( i s s e t ( $ th i s −> r e spon s e s [ $key ] ) ) {$response = new tweetResponseOauth ( ( ob j e c t ) $ th i s −>

r e spon s e s [ $key ] ) ;

i f ( i s s e t ( $response −> r e s p −> header −> s t a tu s ) ) {$response −> r e s p −> header −> s t a tu s =

$response −> r e s p −> code ;$ th i s −> header = $response −> r e s p −>

header ;}

i f ( $response −> r e s p −> code !== 200) {throw new tweetException ( $response −> r e s p

−> code . ’ | Request Fa i l ed : ’ .$ response −> r e s p −> data −> e r r o r s [ 0 ]−> message ) ;

}

re turn $response ;}

}

$running = $runn ing cur l ;

} whi le ( $ runn ing cur l > 0) ;

}

pr i va t e func t i on setResponse ( $key ) {whi le ( $done = cu r l mu l t i i n f o r e a d ( $ th i s −> mch ) ) {

$key = ( s t r i n g ) $done [ ’ handle ’ ] ;

$h eade r s i z e = c u r l g e t i n f o ( $done [ ’ handle ’ ] , CURLINFO HEADER SIZE) ;$header = subst r ( c u r l mu l t i g e t c on t en t ( $done [ ’ handle ’ ] ) , 0 ,

$h eade r s i z e ) ;$body = subst r ( c u r l mu l t i g e t c on t en t ( $done [ ’ handle ’ ] ) , $h eade r s i z e ) ;

$ t h i s −> r e spon s e s [ $key ] [ ’ header ’ ] = $header ;$ th i s −> r e spon s e s [ $key ] [ ’ data ’ ] = $body ;

f o r each ( $th i s−> p r o p e r t i e s as $cu r l k ey => $value ) {$ th i s −> r e spon s e s [ $key ] [ $ cu r l k ey ] = c u r l g e t i n f o ( $done [ ’

handle ’ ] , $value ) ;

cu r l mu l t i r emove hand l e ( $ th i s −> mch , $done [ ’ handle ’ ] ) ;}

}}

}

c l a s s tweetResponseOauth {

pr i va t e $ c on s t r u c t ;

pub l i c func t i on c on s t r u c t ( $resp ) {$ th i s −> r e s p = $resp ;

i f ( s t rpo s ( $ th i s −> r e s p −> type , ’ json ’ ) !== FALSE) {$ th i s −> r e s p −> data = json decode ( $ th i s −> r e s p −> data ) ;

257

Page 269: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$ th i s −> r e s p −> header = ( ob j e c t ) $ th i s −> formatHeader ( $ th i s −>r e s p −> header ) ;

}}

pub l i c func t i on g e t ($name) {i f ( $ th i s −> r e s p −> code < 200 | | $ th i s −> r e s p −> code > 299)

return FALSE;

i f ( i s s t r i n g ( $ th i s −> r e s p −> data ) ) {pa r s e s t r ( $ th i s −> r e s p −> data , $ r e s u l t ) ;

} e l s e {$ r e s u l t = $ th i s −> r e s p −> data ;

}

f o r each ( $ r e s u l t as $k => $v ) {$ th i s −> $k = $v ;

}

i f ( $name === ’ r e s u l t ’ ) {re turn $ r e s u l t ;

}

re turn $ r e s u l t [ $name ] ;}

pr i va t e func t i on formatHeader ( $header ) {$ r e s u l t = explode (”\n” , $header ) ;

$ r e su l t h e ad e r = array ( ) ;f o r each ( $ r e s u l t as $k => $v ) {

i f ( $k == 0 | | trim ( $v ) == ’ ’ )cont inue ;

l i s t ( $key , $value ) = array pad ( explode ( ’ : ’ , $v ) , 2 , nu l l ) ;$ r e s u l t h e ad e r [ s t r t o l owe r ( trim ( $key ) ) ] = trim ( $value ) ;

}

re turn $ r e su l t h e ad e r ;}

}

c l a s s tweetOauth extends tweetConnection {

pr i va t e $ ob j ;p r i va t e $ tokens = array ( ) ;p r i va t e $ au tho r i z a t i onUr l = ’ http :// api . tw i t t e r . com/oauth/ author ize ’ ; // Login each

timepr i va t e $ au then t i c a t i onUr l = ’ http :// api . tw i t t e r . com/oauth/ authent i cate ’ ; // Keep

logged inp r i va t e $ requestTokenUrl = ’ http :// api . tw i t t e r . com/oauth/ request token ’ ;p r i va t e $ accessTokenUrl = ’ http :// api . tw i t t e r . com/oauth/ acces s token ’ ;p r i va t e $ s ignatureMethod = ’HMAC−SHA1 ’ ;p r i va t e $ v e r s i on = ’ 1 . 0 ’ ;p r i va t e $ ap iVer s i on = ’ 1 . 1 ’ ;p r i va t e $ ap iUr l = ’ http :// api . tw i t t e r . com ’ ;p r i va t e $ sea r chUr l = ’ http :// search . tw i t t e r . com ’ ;p r i va t e $ responseType = ’ json ’ ;p r i va t e $ c a l l b a ck = NULL;p r i va t e $ e r r o r s = array ( ) ;p r i va t e $ enable debug = FALSE;

func t i on c on s t r u c t ( ) {parent : : c o n s t r u c t ( ) ;

$ t h i s −> ob j = &ge t i n s t an c e ( ) ;$ t h i s −> ob j −> load −> c on f i g ( ’ tweet ’ ) ;$ t h i s −> ob j −> load −> l i b r a r y ( ’ s e s s i on ’ ) ;$ t h i s −> ob j −> load −> l i b r a r y ( ’ un i t t e s t ’ ) ;$ t h i s −> ob j −> load −> he lpe r ( ’ ur l ’ ) ;

$ t h i s −> tokens = array (’ consumer key ’ => $ th i s −> ob j −> c on f i g −> item ( ’ tweet consumer key

’ ) ,’ consumer secret ’ => $ th i s −> ob j −> c on f i g −> item ( ’

tweet consumer secret ’ ) ,’ acces s key ’ => $ th i s −> getAccessKey ( ) ,’ a c c e s s s e c r e t ’ => $ th i s −> ge tAcce s sSe c r e t ( )

) ;

$ t h i s −> checkLogin ( ) ;}

f unc t i on d e s t r u c t ( ) {i f ( ! $ t h i s −> enable debug )

return ;

i f ( ! empty ( $ th i s −> e r r o r s ) ) {f o r each ( $th i s−> e r r o r s as $key => $e ) {

echo ’<pre>’ . $e . ’</pre > ’ ;}

}}

pub l i c func t i on enable debug ( $debug ) {$debug = ( bool ) $debug ;$ th i s −> enable debug = $debug ;

}

258

Page 270: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

pub l i c func t i on getHeader ( ) {re turn $ th i s −> header ;

}

pub l i c func t i on c a l l ( $method , $path , $args = NULL) {$response = $ th i s −> httpRequest ( s t r toupper ( $method ) , $ th i s −> ap iUr l . ’/ ’

. $ t h i s −> ap iVer s i on . ’/ ’ . $path . ’ . ’ . $ t h i s −> responseType , $args) ;

// var dump ( $response ) ;// d i e ( ) ;

r e turn ( $response === NULL) ? FALSE : $response −> r e s u l t ;}

pub l i c func t i on search ( $args = NULL) {$response = $ th i s −> httpRequest ( ’GET’ , $ th i s −> s ea r chUr l . ’/ search . ’ .

$ t h i s −> responseType , $args ) ;

r e turn ( $response === NULL) ? FALSE : $response −> r e s u l t ;}

pub l i c func t i on loggedIn ( ) {$acce s s key = $ th i s −> getAccessKey ( ) ;$ a c c e s s s e c r e t = $ th i s −> ge tAcce s sSe c r e t ( ) ;

$ loggedIn = FALSE;

i f ( $ th i s −> getAccessKey ( ) !== NULL && $th i s −> ge tAcce s sSe c r e t ( ) !== NULL){

$ loggedIn = TRUE;}

$ th i s −> ob j −> uni t −> run ( $loggedIn , TRUE, ’ Logged In ’ ) ;r e turn $ loggedIn ;

}

pr i va t e func t i on checkLogin ( ) {i f ( i s s e t ($ GET [ ’ oauth token ’ ] ) ) {

$ th i s −> setAccessKey ($ GET [ ’ oauth token ’ ] ) ;$token = $th i s −> getAccessToken ( ) ;

$token = $token −> r e s u l t ;

$token = ( i s b o o l ( $token ) ) ? $token : ( ob j e c t ) $token ;

i f ( ! empty ( $token −> oauth token ) && ! empty ( $token −>oau th token s e c r e t ) ) {

$ th i s −> setAccessKey ( $token −> oauth token ) ;$ th i s −> s e tAc c e s sS e c r e t ( $token −> oau th token s e c r e t ) ;

}

r e d i r e c t ( c u r r e n t u r l ( ) ) ;r e turn NULL;

}}

pub l i c func t i on l o g i n ( $ s i g n i n tw i t t e r = f a l s e ) {i f ( ( $ th i s −> getAccessKey ( ) === NULL | | $ th i s −> ge tAcce s sSe c r e t ( ) === NULL

) ) {header ( ’ Locat ion : ’ . $ t h i s −> ge tAuthor i za t i onUr l ( $ s i g n i n tw i t t e r ) )

;r e turn ;

}

re turn $ th i s −> checkLogin ( ) ;}

pub l i c func t i on logout ( ) {$ th i s −> ob j −> s e s s i o n −> unse t use rdata ( ’ tw i t t e r oauth tokens ’ ) ;

}

pub l i c func t i on getTokens ( ) {re turn $ th i s −> tokens ;

}

pr i va t e func t i on getConsumerKey ( ) {re turn $ th i s −> tokens [ ’ consumer key ’ ] ;

}

pr i va t e func t i on getConsumerSecret ( ) {re turn $ th i s −> tokens [ ’ consumer secret ’ ] ;

}

pub l i c func t i on getAccessKey ( ) {re turn $ th i s −> getAccessKey ( ) ;

}

pr i va t e func t i on getAccessKey ( ) {$tokens = $ th i s −> ob j −> s e s s i o n −> userdata ( ’ tw i t t e r oauth tokens ’ ) ;r e turn ( $tokens === FALSE | | ! i s s e t ( $tokens [ ’ acces s key ’ ] ) | | empty ( $tokens [ ’

acces s key ’ ] ) ) ? NULL : $tokens [ ’ acces s key ’ ] ;}

pr i va t e func t i on setAccessKey ( $acce s s key ) {$tokens = $ th i s −> ob j −> s e s s i o n −> userdata ( ’ tw i t t e r oauth tokens ’ ) ;

i f ( $tokens === FALSE | | ! i s a r r a y ( $tokens ) ) {

259

Page 271: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

$tokens = array ( ’ acces s key ’ => $acce s s key ) ;} e l s e {

$tokens [ ’ acces s key ’ ] = $acce s s key ;}

$ th i s −> ob j −> s e s s i o n −> s e t u s e rda t a ( ’ tw i t t e r oauth tokens ’ , $tokens ) ;}

pub l i c func t i on ge tAcce s sSec r e t ( ) {re turn $ th i s −> ge tAcce s sSe c r e t ( ) ;

}

pr i va t e func t i on ge tAcce s sSe c r e t ( ) {$tokens = $ th i s −> ob j −> s e s s i o n −> userdata ( ’ tw i t t e r oauth tokens ’ ) ;r e turn ( $tokens === FALSE | | ! i s s e t ( $tokens [ ’ a c c e s s s e c r e t ’ ] ) | | empty ( $tokens

[ ’ a c c e s s s e c r e t ’ ] ) ) ? NULL : $tokens [ ’ a c c e s s s e c r e t ’ ] ;}

pr i va t e func t i on s e tAc c e s sS e c r e t ( $ a c c e s s s e c r e t ) {$tokens = $ th i s −> ob j −> s e s s i o n −> userdata ( ’ tw i t t e r oauth tokens ’ ) ;

i f ( $tokens === FALSE | | ! i s a r r a y ( $tokens ) ) {$tokens = array ( ’ a c c e s s s e c r e t ’ => $ a c c e s s s e c r e t ) ;

} e l s e {$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 ;

}

$ th i s −> ob j −> s e s s i o n −> s e t u s e rda t a ( ’ tw i t t e r oauth tokens ’ , $tokens ) ;}

pr i va t e func t i on setAccessTokens ( $tokens ) {$ th i s −> setAccessKey ( $tokens [ ’ oauth token ’ ] ) ;$ t h i s −> s e tAc c e s sS e c r e t ( $tokens [ ’ oauth token sec r e t ’ ] ) ;

}

pub l i c func t i on setAccessTokens ( $tokens ) {re turn $ th i s −> setAccessTokens ( $tokens ) ;

}

pr i va t e func t i on ge tAuthor i za t i onUr l ( $ s i g n i n tw i t t e r = f a l s e ) {$token = $ th i s −> getRequestToken ( ) ;i f ( $ s i g n i n tw i t t e r ) {

re turn $ th i s −> au then t i c a t i onUr l . ’? oauth token=’ . $token −>oauth token ;

}re turn $ th i s −> au tho r i z a t i onUr l . ’? oauth token=’ . $token −> oauth token ;

}

pr i va t e func t i on getRequestToken ( ) {re turn $ th i s −> httpRequest ( ’GET’ , $ th i s −> requestTokenUrl ) ;

}

pr i va t e func t i on getAccessToken ( ) {re turn $ th i s −> httpRequest ( ’GET’ , $ th i s −> accessTokenUrl ) ;

}

protec ted func t i on httpRequest ( $method = nul l , $u r l = nul l , $params = nu l l ) {i f ( empty ( $method ) | | empty ( $ur l ) )

re turn FALSE;i f ( empty ( $params [ ’ oauth s ignature ’ ] ) )

$params = $th i s −> prepareParameters ( $method , $url , $params ) ;

i f ( i s s e t ($ REQUEST[ ’ o au t h v e r i f i e r ’ ] ) ){$params [ ” oauth ” ] [ ” o a u t h v e r i f i e r ” ] = $ REQUEST[ ’ o au t h v e r i f i e r ’ ] ;

}

$ th i s −> connect i on = new tweetConnection ( ) ;

t ry {switch ( $method ) {

case ’GET’ :$response = $ th i s −> connect i on −> get ( $ur l , $params )

;$ th i s −> header = $ th i s −> connect i on −> header ;re turn $response ;break ;

case ’POST’ :$response = $ th i s −> connect i on −> post ( $url , $params

) ;$ th i s −> header = $ th i s −> connect i on −> header ;re turn $response ;break ;

case ’PUT’ :re turn NULL;break ;

case ’DELETE’ :re turn NULL;break ;

}} catch ( tweetException $e ) {

$ th i s −> e r r o r s [ ] = $e ;}

}

pr i va t e func t i on ge tCa l lback ( ) {re turn $ th i s −> c a l l b a c k ;

260

Page 272: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

}

pub l i c func t i on se tCa l lback ( $ur l ) {$ th i s −> c a l l b a c k = $ur l ;

}

pr i va t e func t i on prepareParameters ( $method = NULL, $ur l = NULL, $params = NULL) {i f ( empty ( $method ) | | empty ( $ur l ) )

re turn FALSE;

$ca l l back = $ th i s −> getCa l lback ( ) ;

i f ( ! empty ( $ca l l back ) ) {$oauth [ ’ oauth ca l lback ’ ] = $ca l l back ;

}

$ th i s −> s e tCa l lback (NULL) ;

$oauth [ ’ oauth consumer key ’ ] = $ th i s −> getConsumerKey ( ) ;$oauth [ ’ oauth token ’ ] = $ th i s −> getAccessKey ( ) ;$oauth [ ’ oauth nonce ’ ] = $ th i s −> generateNonce ( ) ;$oauth [ ’ oauth timestamp ’ ] = time ( ) ;$oauth [ ’ oauth s ignature method ’ ] = $ th i s −> s ignatureMethod ;$oauth [ ’ oauth vers ion ’ ] = $ th i s −> v e r s i o n ;

array walk ( $oauth , array ( $th i s , ’ encode r f c3986 ’ ) ) ;

i f ( i s a r r a y ( $params ) ) {array walk ( $params , array ( $th i s , ’ encode r f c3986 ’ ) ) ;

}

$encodedParams = array merge ( $oauth , ( array ) $params ) ;

k so r t ( $encodedParams ) ;

$oauth [ ’ oauth s ignature ’ ] = $ th i s −> encode r f c3986 ( $ th i s −>gene ra t eS i gna tu r e ( $method , $ur l , $encodedParams ) ) ;

r e turn array ( ’ request ’ => $params , ’ oauth ’ => $oauth ) ;}

pr i va t e func t i on generateNonce ( ) {re turn md5( uniq id ( rand ( ) , TRUE) ) ;

}

pr i va t e func t i on encode r f c3986 ( $ s t r i n g ) {re turn s t r i r e p l a c e ( array ( ’+ ’ , ’%7E’ ) , array ( ’ ’ , ’ ˜ ’ ) , rawurlencode ( $ s t r i n g ) )

;}

pr i va t e func t i on gene ra t eS i gna tu r e ( $method = nul l , $u r l = nul l , $params = nu l l ) {i f ( empty ( $method ) | | empty ( $ur l ) )

re turn FALSE;

// concatenat ing$concatenatedParams = ’ ’ ;

f o r each ( $params as $k => $v ) {$k = $th i s −> encode r f c3986 ( $k ) ;$v = $ th i s −> encode r f c3986 ( $v ) ;$concatenatedParams .= ”{$k}={$v}&”;

}

$concatenatedParams = $th i s −> encode r f c3986 ( subs t r ( $concatenatedParams , 0 ,−1) ) ;

// normal ize u r l$normal izedUrl = $ th i s −> encode r f c3986 ( $ th i s −> normal i z eUr l ( $ur l ) ) ;$method = $th i s −> encode r f c3986 ( $method ) ;// don ’ t need t h i s but why not ?

$s i gnatureBaseSt r ing = ”{$method}&{$normal izedUrl}&{$concatenatedParams }” ;re turn $ th i s −> s i g nS t r i n g ( $ s i gnatureBaseSt r ing ) ;

}

pr i va t e func t i on normal i z eUr l ( $ur l = NULL) {$ur lPar t s = pa r s e u r l ( $ur l ) ;

i f ( ! i s s e t ( $ur lPar t s [ ’ port ’ ] ) )$ur lPar t s [ ’ port ’ ] = 80 ;

$scheme = s t r t o l owe r ( $ur lPar t s [ ’ scheme ’ ] ) ;$host = s t r t o l owe r ( $ur lPar t s [ ’ host ’ ] ) ;$port = i n t v a l ( $ur lPar t s [ ’ port ’ ] ) ;

$ r e t va l = ”{$scheme } ://{ $host }” ;

i f ( $port > 0 && ( $scheme === ’ http ’ && $port !== 80) | | ( $scheme === ’ https ’&& $port !== 443) ) {

$ r e t va l .= ”:{ $port }” ;}

$ r e t va l .= $ur lPar t s [ ’ path ’ ] ;

i f ( ! empty ( $ur lPar t s [ ’ query ’ ] ) ) {$ r e t va l .= ”?{ $ur lPar t s [ ’ query ’ ] } ” ;

}

re turn $ r e t va l ;}

261

Page 273: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

pr i va t e func t i on s i g nS t r i n g ( $ s t r i n g ) {$ r e t va l = FALSE;switch ( $th i s−> s ignatureMethod ) {

case ’HMAC−SHA1’ :$key = $ th i s −> encode r f c3986 ( $ th i s −> getConsumerSecret ( ) )

. ’& ’ . $ t h i s −> encode r f c3986 ( $ th i s −>ge tAcce s sSe c r e t ( ) ) ;

$ r e t va l = base64 encode ( hash hmac ( ’ sha1 ’ , $ s t r ing , $key , t rue )) ;

break ;}

re turn $ r e t va l ;}

}

/∗ End o f f i l e tweet . php ∗//∗ Locat ion : . / app l i c a t i on / l i b r a r i e s / tweet . 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 : white ; }: : moz−s e l e c t i o n { background−c o l o r : #E13300 ; c o l o r : white ; }: : webkit−s e l e c t i o n { background−c o l o r : #E13300 ; c o l o r : white ; }

body {background−c o l o r : # f f f f f f ;margin−top : 10px ;margin−bottom : 10px ;margin− l e f t : 100px ;margin−r i gh t : 100px ;font : 13px/20px normal He lvet i ca , Ar ia l , sans−s e r i f ;c o l o r : #4F5155 ;

}

a {c o l o r : #003399;background−c o l o r : t ransparent ;font−weight : normal ;

}

h1 {c o l o r : #f f f ;background−c o l o r : t ransparent ;border−bottom : 1px s o l i d #D0D0D0 ;font−s i z e : 19px ;font−weight : normal ;margin : 0 0 14px 0 ;padding : 14px 15px 10px 15px ;

}

code {font−f ami ly : Consolas , Monaco , Cour ier New, Courier , monospace ;font−s i z e : 12px ;background−c o l o r : #f 9 f 9 f 9 ;border : 1px s o l i d #D0D0D0 ;c o l o r : #002166;d i sp l ay : b lock ;margin : 14px 0 14px 0 ;padding : 12px 10px 12px 10px ;

}

#body{margin : 0 15px 0 15px ;

}

p . f o o t e r {text−a l i gn : r i gh t ;font−s i z e : 11px ;border−top : 1px s o l i d #D0D0D0 ;l i n e−he ight : 32px ;padding : 0 10px 0 10px ;margin : 20px 0 0 0 ;

}

#loginMainBox{width : 860px ; /∗500px∗/margin−top : 10px ;margin− l e f t : 70px ; /∗250px∗/−webkit−box−shadow : 0 0 8px #D0D0D0 ;−moz−border−rad ius : 10px ;border−top−l e f t−rad ius : 10px 5px ;border−top−r ight−rad ius : 10px ;

}

#resetPasswordBox{width : 500px ;margin−top : 10px ;margin− l e f t : 250px ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;−moz−border−rad ius : 10px ;border−top−l e f t−rad ius : 10px 5px ;border−top−r ight−rad ius : 10px ;

}

262

Page 274: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

#loginBox{width : 300px ;margin− l e f t : 280px ; /∗90px∗/

}

#logoutBox{width : 350px ;margin− l e f t : 750px ;margin−bottom : 10px ;

}

#signupBox{width : 400px ;margin− l e f t : 50px ;

}

#aboutBox{width : 950px ;margin− l e f t : 0px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#conta ine r {width : 1023px ;margin−top : 10px ;margin− l e f t : 60px ;margin−r i gh t : 40px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#header{

background−image : u r l ( ’ . . / layout / images /HeasFimBanner . jpg ’ ) ;he ight : 142px ;width : 1000px ;margin : 10px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;

}

#manageUserAccountsBox{width : 999px ;margin− l e f t : −5px ;margin−top : 50px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;−moz−border−rad ius : 10px ;border−top−l e f t−rad ius : 10px 5px ;border−top−r ight−rad ius : 10px ;

}

#manageContentBox{width : 999px ;margin− l e f t : −5px ;margin−top : 50px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;−moz−border−rad ius : 10px ;border−top−l e f t−rad ius : 10px 5px ;border−top−r ight−rad ius : 10px ;

}

#userContentBox{width : 999px ;margin− l e f t : −5px ;margin−top : 50px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;−moz−border−rad ius : 10px ;border−top−l e f t−rad ius : 10px 5px ;border−top−r ight−rad ius : 10px ;

}

#manageUserAccountsHeading{background−c o l o r : #CC0000 ;c o l o r : # f f f f f f ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#manageContentHeading{background−c o l o r : #CC0000 ;c o l o r : # f f f f f f ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#userContentHeading{background−c o l o r : #CC0000 ;c o l o r : # f f f f f f ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

263

Page 275: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

#loginHeading{width : 860px ; /∗500px∗/margin− l e f t : 0px ;background−c o l o r : #CC0000 ;c o l o r : # f f f f f f ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#reg i s t e rHead ing {width : 860px ; /∗500px∗/margin− l e f t : 0px ;background−c o l o r : #CC0000 ;c o l o r : # f f f f f f ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#userRecipesViewHeading{background−c o l o r : # f f f f f f ;c o l o r : #CC0000 ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;/∗ po s i t i o n : abso lu te ;top : 275px ;width : 318px ;∗/

}

#userRecipesBox{

}

#userAchievementsViewHeading{background−c o l o r : # f f f f f f ;c o l o r : #CC0000 ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;/∗ po s i t i o n : abso lu te ;top : 275px ;width : 318px ;∗/

}

#userAchievementsBox{

}

#userHealthTipsViewHeading{background−c o l o r : # f f f f f f ;c o l o r : #CC0000 ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;/∗ po s i t i o n : abso lu te ;top : 275px ;width : 318px ;∗/

}

#userHealthTipsBox{

}

#addUserBox{margin− l e f t : 10px ;

}

#contentMenuBox{margin− l e f t : 10px ;

}

#userMenuBox{margin− l e f t : 10px ;

}

#viewUsersBox{width : 985px ;margin− l e f t : 5px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#viewUsersBox tab l e {border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;c o l o r : #000000;

}

#viewUsersBox td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#viewUsersBox th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;

264

Page 276: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

c o l o r : white ;}

#userFeedHeading{width : 985px ;margin− l e f t : 5px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#userFeedHeading tab l e {border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;c o l o r : #000000;width : 980px ;

}

#userFeedHeading td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#userFeedHeading t r {border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#userFeedHeading th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;c o l o r : white ;

}

#userViewBox{width : 985px ;margin− l e f t : 5px ;border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;

}

#userViewBox tab l e {border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;c o l o r : #000000;width : 980px ;

}

#userViewBox td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#userViewBox t r {border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#userViewBox th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;c o l o r : white ;

}

#userSearchFELDialog tab l e {border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;c o l o r : #000000;

}

#userSearchFELDialog td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#userSearchFELDialog th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;c o l o r : white ;

}

#viewFPDialog tab l e {border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;

265

Page 277: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

c o l o r : #000000;}

#viewFPDialog td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#viewFPDialog th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;c o l o r : white ;

}

/∗CREATE RECIPE GUIDELINES∗/#hea l thCondit ionsGuide l inesModalDia log tab l e {

border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;c o l o r : #000000;

}

#healthCondit ionsGuide l inesModalDia log td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#healthCondit ionsGuide l inesModalDia log th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;c o l o r : white ;

}

/∗VIEW CREATED RECIPES∗/#viewCreatedRecipesDia log tab l e {

border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;c o l o r : #000000;

}

#viewCreatedRecipesDia log td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#viewCreatedRecipesDia log th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;c o l o r : white ;

}. redbox {

border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;c o l o r : white ;

}

/∗ADD MEAL∗//∗VIEW CREATED RECIPES∗/#addMealDialog tab l e {

border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;c o l o r : #000000;

}

#addMealDialog td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#addMealDialog th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;background−c o l o r : #CC0000 ;c o l o r : white ;

}

#addMealButton{width : 120px ;

}

/∗PLAN DAILY MEALS∗/#planDai lyMealsDia log tab l e {

border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;font−f ami ly : Verdana ;font−s i z e : 10pt ;

266

Page 278: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

c o l o r : #000000;}

#planDai lyMealsDia log td{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #D0D0D0 ;text−a l i gn : c ente r ;

}

#planDai lyMealsDia log th{border : 1px s o l i d #D0D0D0 ;−webkit−box−shadow : 0 0 8px #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 {

border : 1px s o l i d #D0D0D0 ;}

#icons {margin : 0 ;padding : 0 ;

}#icons l i {

margin : 2px ;p o s i t i o n : r e l a t i v e ;padding : 4px 0 ;cur so r : po in t e r ;f l o a t : l e f t ;l i s t −s t y l e : none ;

}#icons span . ui−i con {

f l o a t : l e f t ;margin : 0 4px ;

}a . dp−choose−date {

f l o a t : l e f t ;width : 16px ;he ight : 16px ;padding : 0 ;margin : 5px 3px 0 ;d i sp l ay : b lock ;text−indent : −2000px ;over f low : hidden ;background : u r l ( . . / layout / jquery−ui −1 .10 .3 . custom/development−bundle /demos/

datep i cke r / images / ca lendar . g i f ) no−repeat ;}a . dp−choose−date . dp−d i sab l ed {

background−po s i t i o n : 0 −20px ;cur so r : d e f au l t ;

}/∗ makes the input f i e l d sho r t e r once the date p i cke r code∗ has run ( to a l low space f o r the ca lendar i con∗/input . dp−app l i ed {

width : 140px ;f l o a t : l e f t ;

}

. v e r i f y {margin−top : −7px ;margin− l e f t : 9px ;p o s i t i o n : abso lu te ;width : 402px ;he ight : 16px ;

}

. noc l o s e . ui−dia log−t i t l e b a r−c l o s e {d i sp l ay : none ;

}

. us−top−nav {width : auto ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 893px ;

}

. s e t t i n g s−person {f l o a t : l e f t ;

}

. s e t t i n g s−t r i a n g l e {f l o a t : l e f t ;

}

. us−inner−nav {width : 172px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;top : 30px ;l e f t : −145px ;

}

. us−inner−nav−opt ion {−webkit−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

Page 279: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

−o−t r a n s i t i o n : . 2 s ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. us−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}/∗∗∗∗∗∗∗∗∗∗∗/. cm−top−nav {

width : auto ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 893px ;

}

. s e t t i n g s−person {f l o a t : l e f t ;

}

. s e t t i n g s−t r i a n g l e {f l o a t : l e f t ;

}

. cm−inner−nav {width : 172px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;top : 30px ;l e f t : −210px ;

}

. cm−inner−nav−opt ion {−webkit−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 ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. cm−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}/∗∗∗∗∗∗∗∗∗∗∗/. ad−top−nav {

width : auto ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 893px ;

}

. s e t t i n g s−person {f l o a t : l e f t ;

}

. s e t t i n g s−t r i a n g l e {f l o a t : l e f t ;

}

. ad−inner−nav {width : 172px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;top : 30px ;l e f t : −181px ;

}

. ad−inner−nav−opt ion {−webkit−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 ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. ad−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}

/∗CONTENT MANAGER NAVIGATION∗/. content−top−nav {

width : 200px ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 170px ;

}

. content−t r i a n g l e {f l o a t : l e f t ;

}

. content−p lu s th i ck {f l o a t : l e f t ;

}

. content−inner−nav {width : 135px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;

268

Page 280: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

top : −4px ;l e f t : 0px ;

}

. content−inner−nav−opt ion {−webkit−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 ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. content−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}

. content−content−top−nav {width : 200px ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 307px ;

}

. content−content−t r i a n g l e {f l o a t : l e f t ;

}

. content−content−s t a r {f l o a t : l e f t ;

}

. content−content−inner−nav {width : 150px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;top : −4px ;l e f t : 0px ;

}

. content−content−inner−nav−opt ion {−webkit−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 ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. content−content−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}

/∗USER NAVIGATION∗/. user−top−nav {

width : 200px ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 170px ;

}

. user−t r i a n g l e {f l o a t : l e f t ;

}

. user−note {f l o a t : l e f t ;

}

. user−inner−nav {width : 157px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;top : −4px ;l e f t : 0px ;

}

. user−inner−nav−opt ion {−webkit−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 ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. user−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}

. user−user−top−nav {width : 200px ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 329px ;

}

. user−user−t r i a n g l e {f l o a t : l e f t ;

}

. user−user−c l i pboard {

269

Page 281: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

f l o a t : l e f t ;}

. user−user−inner−nav {width : 147px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;top : −4px ;l e f t : 0px ;

}

. user−user−inner−nav−opt ion {−webkit−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 ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. user−user−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}

. user−user−user−top−nav {width : 200px ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 478px ;

}

. user−user−user−t r i a n g l e {f l o a t : l e f t ;

}

. user−user−user−s t a r {f l o a t : l e f t ;

}

. user−user−user−inner−nav {width : 183px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;top : −4px ;l e f t : 0px ;

}

. user−user−user−inner−nav−opt ion {−webkit−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 ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. user−user−user−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}

. user−user−user−user−top−nav {width : 240px ;p o s i t i o n : abso lu te ;top : 175px ;l e f t : 663px ;

}

. user−user−user−user−t r i a n g l e {f l o a t : l e f t ;

}

. user−user−user−user−search {f l o a t : l e f t ;

}

. user−user−user−user−inner−nav {width : 228px ;text−a l i gn : c ente r ;p o s i t i o n : abso lu te ;top : −4px ;l e f t : 0px ;

}

. user−user−user−user−inner−nav−opt ion {−webkit−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 ;t r a n s i t i o n : . 2 s ;font−weight : bold ;

}

. user−user−user−user−inner−nav−opt ion : hover {c o l o r :#cc0000 ;

}

/∗NEWSFEED CSS∗/

270

Page 282: dspace.cas.upm.edu.phdspace.cas.upm.edu.ph/jspui/bitstream/123456789/17... · University of the Philippines Manila College of Arts and Sciences Department of Physical Sciences and

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 encourage-

ment, 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