319a76de3c5e08236e7172948ac75dccc3b77f83
[atutor.git] / mods / atutor_opencaps / opencaps / include / vitals.inc.php
1 <?php
2 /*
3  * OpenCaps
4  * http://opencaps.atrc.utoronto.ca
5  * 
6  * Copyright 2010 Heidi Hazelton
7  * Adaptive Technology Resource Centre, University of Toronto
8  * 
9  * Licensed under the Educational Community License (ECL), Version 2.0. 
10  * You may not use this file except in compliance with this License.
11  * http://www.opensource.org/licenses/ecl2.php
12  * 
13  */
14
15 if (!defined('INCLUDE_PATH')) {
16         define('INCLUDE_PATH', 'include/');
17 }
18
19 require(INCLUDE_PATH.'classes/user_class.php');
20 require(INCLUDE_PATH.'classes/db_class.php');
21 require(INCLUDE_PATH.'classes/project_class.php');
22 require(INCLUDE_PATH.'classes/clip_class.php');
23 require(INCLUDE_PATH.'classes/caption_class.php');
24 require(INCLUDE_PATH.'classes/time_class.php');
25 require(INCLUDE_PATH.'classes/system_class.php');
26 \r
27 @session_start();
28
29 require(INCLUDE_PATH.'config.inc.php');
30
31
32 $supported_ext = array('mov', 'qt', 'mp4', 'm4v', 'mpg', 'mpeg', 'dv', 'mp3', 'wav', 'aac', 'midi', 'au', 'avi', 'aiff');
33 $pub_pages = array("index.php", "login.php", "register.php", "start.php", "start_remote.php", "workflow.php");
34
35 $page = explode('/',$_SERVER['PHP_SELF']); 
36 $page = end($page);
37
38 $base_url = substr('http://'.$_SERVER["SERVER_NAME"].$_SERVER["SCRIPT_NAME"], 0, -(strlen($page)));\r
39
40 function my_add_null_slashes( $string ) {
41     return mysql_real_escape_string(stripslashes($string));
42 }
43 function my_null_slashes($string) {
44         return $string;
45 }
46 if ( get_magic_quotes_gpc() ) {
47         $addslashes   = 'my_add_null_slashes';
48         $stripslashes = 'stripslashes';
49 } else {
50         $addslashes   = 'mysql_real_escape_string';
51         $stripslashes = 'my_null_slashes';
52 }
53
54 if (get_magic_quotes_gpc()) {
55         $addslashes   = 'my_add_null_slashes';
56         $stripslashes = 'my_null_slashes';
57 } else {
58         $addslashes   = 'addslashes';
59         $stripslashes = 'stripslashes';
60 }
61
62
63 /* 
64  * check for valid user 
65  */
66
67 $this_user = new user($_SESSION['mid'], $_SESSION['username']);
68
69 if (!in_array($page, $pub_pages) && (!isset($_SESSION['valid_user']) || !$_SESSION['valid_user'] || !isset($_SESSION['mid']) || !$_SESSION['mid']) ) {
70         header("Location:start.php");
71         exit;
72 }
73
74 /* check if system connection */
75 if (ACTIVE_SYSTEM)
76         $this_system = new system(ACTIVE_SYSTEM);               
77
78
79 /* 
80  * connect to db 
81  */
82 if (!isset($this_db) && !DISABLE_LOCAL) 
83         $this_db = new database();      
84
85         
86 /*
87  * load project
88  */
89 if (isset($_SESSION['pid']) || $page=="workflow.php") {
90         $this_proj = new project();
91         $this_proj->owner = &$this_user;
92         
93         if (isset($_SESSION['pid']))    
94                 $this_proj->id = $_SESSION['pid'];
95         
96         if (!empty($this_proj->id))
97                 setVals();      
98 }
99
100 function setVals() {
101         global $this_proj, $stripslashes;
102         
103         $json = json_decode($stripslashes(@file_get_contents(INCLUDE_PATH.'../projects/'.$_SESSION['pid'].'/opencaps.json')));
104         
105         $this_proj->id = $json->id;
106         $this_proj->name = $json->name;
107         //$this_proj->prefs = $json->prefs;
108
109         $this_proj->media_loc = $json->media_loc; 
110         $this_proj->media_height = $json->media_height;
111         $this_proj->media_width = $json->media_width;
112         $this_proj->duration = $json->duration;
113         $this_proj->layout = $json->layout;
114         
115         $this_proj->caption_loc = $json->caption_loc;
116         $this_proj->clip_collection = $json->clip_collection;
117
118 }
119
120 /* 
121  * check for valid project 
122  
123 if ($page != "index.php" && $page != "login.php" && $page != "logout.php" && $page != "register.php" && $page != "start.php" && $page != "adminTasks.php") { 
124         if (!isset($_SESSION['pid']) && empty($_SESSION['pid'])) {
125                 echo "Project not loaded.";
126                 exit;
127         }
128
129 */
130
131
132 //check if using firefox
133 /*if(!strstr($_SERVER['HTTP_USER_AGENT'], "Firefox")) {
134         $_SESSION['errors'][] = "At this time, Capscribe Web requires a Firefox browser.";
135         include(INCLUDE_PATH.'basic_header.inc.php');
136         include(INCLUDE_PATH.'footer.inc.php'); 
137         exit;
138 }*/
139
140 ?>