function mobile_event(&$vars) { if (!($_SERVER['REMOTE_ADDR'] == '204.244.102.2')) { trigger_error('Sorry but your IP address is unlike the Zeep server', E_USER_ERROR); } extract($vars); $Post =& $db->model('Post'); $Identity =& $db->model('Identity'); if ($_POST['event'] == 'MO') { // Array ( [sms_prefix] => omb__ [short_code] => 88147 [uid] => 243132 // [body] => test from deep [min] => +15035554444 [event] => MO ) $p = $Post->base(); $p->set_value('profile_id', $_POST['uid']); $p->set_value('parent_id', 0); $p->set_value('title', $_POST['body']); $p->save_changes(); $i = $Identity->find($_POST['uid']); if ($i) { $p->set_etag($i->person_id); } $response->set_var('profile', $i); load_apps(); trigger_after('insert_from_post', $Post, $p); $response = ""; } else { $response = "Welcome to " . environment('site_title'); } $header = array("Status: 200 OK", "Date: " . gmdate(DATE_RFC822), "Content-Type: text/plain", "Content-Length: " . strval(strlen($response))); foreach ($header as $str) { header($str); } echo substr($response, 0, 100); exit; }
function View() { $this->named_vars = array(); $this->header_sent = false; global $db; global $request; $env =& environment(); if (isset($request->resource)) { $this->collection = new Collection($request->resource); } else { $this->collection = new Collection(null); } $this->named_vars['db'] =& $db; $this->named_vars['request'] =& $request; $this->named_vars['collection'] =& $this->collection; $this->named_vars['response'] =& $this; if (get_profile_id()) { $this->named_vars['profile'] =& get_profile(); } else { $this->named_vars['profile'] = false; } if (isset($request->resource) && $request->resource != 'introspection') { $this->named_vars['resource'] =& $db->get_table($request->resource); } else { $this->named_vars['resource'] = false; } $this->named_vars['prefix'] = $db->prefix; $this->controller = $request->controller; load_apps(); $controller_path = controller_path(); // check for a controller file in controllers/[resource].php if (isset($request->resource)) { $cont = $controller_path . $request->resource . ".php"; if (file_exists($cont)) { $this->controller = $request->resource . ".php"; } elseif (isset($request->templates_resource[$request->resource]) && file_exists($controller_path . $request->templates_resource[$request->resource] . ".php")) { $this->controller = $request->templates_resource[$request->resource] . ".php"; } else { if (isset($GLOBALS['PATH']['apps'])) { foreach ($GLOBALS['PATH']['apps'] as $k => $v) { if (file_exists($v['controller_path'] . $request->resource . ".php")) { $this->controller = $request->resource . ".php"; $controller_path = $v['controller_path']; } } } } } if (is_file($controller_path . $this->controller)) { require_once $controller_path . $this->controller; } else { trigger_error('Sorry, the controller was not found at ' . $controller_path . $this->controller, E_USER_ERROR); } if (!isset($env['content_types'])) { trigger_error('Sorry, the content_types array was not found in the configuration file', E_USER_ERROR); } $this->negotiator = HTTP_Negotiate::choose($env['content_types']); }
function get_backstage_data($type = 'index') { $apps = load_apps(); $list = NULL; foreach ($apps as $a) { $fun_name = $a['u2_folder'] . '_' . $type; if (function_exists($fun_name)) { $list[$a['u2_folder']] = $fun_name(); } } return $list; }
function handle_posted_file($filename = "", $att, $profile) { global $db, $request, $response; $response->set_var('profile', $profile); load_apps(); if (isset($_FILES['media']['tmp_name'])) { $table = 'uploads'; } else { $table = 'posts'; } $modelvar = classify($table); $_FILES = array(strtolower($modelvar) => array('name' => array('attachment' => $filename), 'tmp_name' => array('attachment' => $att))); $Post =& $db->model('Post'); $Upload =& $db->model('Upload'); $field = 'attachment'; $request->set_param('resource', $table); $request->set_param(array(strtolower(classify($table)), $field), $att); trigger_before('insert_from_post', ${$modelvar}, $request); $content_type = 'text/html'; $rec = ${$modelvar}->base(); $content_type = type_of($filename); $rec->set_value('profile_id', get_profile_id()); $rec->set_value('parent_id', 0); if (isset($request->params['message'])) { $rec->set_value('title', $request->params['message']); } else { $rec->set_value('title', ''); } if ($table == 'uploads') { $rec->set_value('tmp_name', 'new'); } $upload_types = environment('upload_types'); if (!$upload_types) { $upload_types = array('jpg', 'jpeg', 'png', 'gif'); } $ext = extension_for(type_of($filename)); if (!in_array($ext, $upload_types)) { trigger_error('Sorry, this site only allows the following file types: ' . implode(',', $upload_types), E_USER_ERROR); } $rec->set_value($field, $att); $rec->save_changes(); $tmp = $att; if (is_jpg($tmp)) { $thumbsize = environment('max_pixels'); $Thumbnail =& $db->model('Thumbnail'); $t = $Thumbnail->base(); $newthumb = tempnam("/tmp", "new" . $rec->id . ".jpg"); resize_jpeg($tmp, $newthumb, $thumbsize); $t->set_value('target_id', $atomentry->id); $t->save_changes(); update_uploadsfile('thumbnails', $t->id, $newthumb); $t->set_etag(); } $atomentry = ${$modelvar}->set_metadata($rec, $content_type, $table, 'id'); ${$modelvar}->set_categories($rec, $request, $atomentry); $url = $request->url_for(array('resource' => $table, 'id' => $rec->id)); // $title = substr($rec->title,0,140); // $over = ((strlen($title) + strlen($url) + 1) - 140); // if ($over > 0) // $rec->set_value('title',substr($title,0,-$over)." ".$url); // else // $rec->set_value('title',$title." ".$url); // $rec->save_changes(); trigger_after('insert_from_post', ${$modelvar}, $rec); return true; }