public function public_data($event, $allpublic = false) { $this->geo_tolerance($event, $allpublic); foreach ($event as $k => $v) { if (substr($k, 0, 2) == 'd_') { unset($event[$k]); } } if (isset($event['img']) && $event['img'] && !is_array($event['img'])) { $image = new imageModel($event['img']); unset($event['img']); $data = $image->data(); foreach ($data as $k => $v) { if ($k == 'user' || $k == 'src' || substr($k, 0, 2) == 'd_') { continue; } $event['img'][$k] = $v; } } foreach (['id', 'user', 'parent', 'active', 'min_guests', 'max_guests', 'unlisted', 'fullhouse', 'ical_id', 'transfer', 'change', 'active_err'] as $k) { unset($event[$k]); } return $event; }
public function get_observe() { $this->requiresLogin(true); $obs = []; foreach (scandir(__DIR__ . '/../observer/en') as $dir) { if ($dir[0] == '.') { continue; } $obs[] = $dir; } if (!$this->id) { return $this->status($obs, false, 'observers'); } Bootstrap::$main->session('time_delta', Bootstrap::$main->user['delta']); Bootstrap::$main->human_datetime_format(); $data = []; $data['cancel_reason'] = 'Bo tak'; $data['host'] = Bootstrap::$main->user; $data['guest'] = Bootstrap::$main->user; $guest = new guestModel(); $guests = $guest->getForUser($data['guest']['id']); $data['data'] = $guests[0]; $event = new eventModel(); $events = $event->get_for_user($data['guest']['id']); $data['event'] = $events[0]; $image = new imageModel($data['event']['img']); $data['event']['img'] = $image->data(); require_once __DIR__ . '/../models/paymentModel.php'; $payment = new paymentModel(); $payments = $payment->getAllForChannel('payu', Bootstrap::$main->now - 7 * 24 * 3600, 99); $data['payment'] = $payments[0]; if (isset($data['payment']['notify'])) { $data['notify'] = json_decode($data['payment']['notify'], true); } return $this->status($obs, Tools::observe($this->id, $data), $this->id); }
protected function upload_file($tmp, $name) { //mydie($this->_media_dir,$this->_media); $ext = @strtolower(end(explode('.', $name))); $user = Bootstrap::$main->user; if (isset($this->data['flowIdentifier'])) { $lp = $this->data['flowIdentifier']; } else { $lp = 1 + $this->image()->getUsersCount($user['id']); } $name = $this->_prefix . '/' . $user['md5hash'] . '/' . md5($lp . '-' . $name) . '.' . $ext; $chunks = false; $original_name = $name; if (isset($this->data['flowTotalChunks']) && $this->data['flowTotalChunks'] > 1 && isset($this->data['flowChunkNumber'])) { $chunks = true; $name .= '.part' . $this->data['flowChunkNumber']; } if ($this->_appengine) { $file = 'gs://' . CloudStorageTools::getDefaultGoogleStorageBucketName() . '/' . $name; move_uploaded_file($tmp, $file); } else { $file = $this->_media_dir . '/' . $name; @mkdir(dirname($file), 0755, true); move_uploaded_file($tmp, $file); //mydie(exif_read_data($tmp)); } if ($chunks) { if (!$this->checkChunks($file)) { return false; } $name = $original_name; $file = preg_replace('/\\.part[0-9]+$/', '', $file); } if (!file_exists($file) || !filesize($file)) { $this->error(18); } $model = new imageModel(); $model->user = $user['id']; $model->src = $name; $model->d_uploaded = Bootstrap::$main->now; $exif = []; $imagesize = @getimagesize($file, $exif); if (!is_array($imagesize) || !$imagesize[0]) { $imagesize = [5000, 5000]; } if (is_array($exif)) { foreach ($exif as $k => $a) { if (substr($a, 0, 4) == 'Exif') { $matches = []; preg_match_all('/[0-9]{4}:[0-9]{2}:[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/', $a, $matches); $d = ''; if (isset($matches[0][1])) { $d = $matches[0][1]; } elseif (isset($matches[0][0])) { $d = $matches[0][0]; } if ($d) { $d = preg_replace('/([0-9]{4}):([0-9]{2}):([0-9]{2})/', '\\1-\\2-\\3', $d); $model->d_taken = $this->strtotime($d); } } } } if ($this->_appengine) { $model->url = CloudStorageTools::getImageServingUrl($file, ['size' => 0 + Bootstrap::$main->getConfig('image_size'), 'secure_url' => Bootstrap::$main->getConfig('protocol') == 'https']); $full = CloudStorageTools::getImageServingUrl($file, ['size' => 1234, 'secure_url' => Bootstrap::$main->getConfig('protocol') == 'https']); $model->full = str_replace('=s1234', '=s' . Bootstrap::$main->getConfig('full_size'), $full); $model->thumbnail = CloudStorageTools::getImageServingUrl($file, ['size' => 0 + Bootstrap::$main->getConfig('thumbnail_size'), 'secure_url' => Bootstrap::$main->getConfig('protocol') == 'https']); $model->square = CloudStorageTools::getImageServingUrl($file, ['size' => 0 + Bootstrap::$main->getConfig('square_size'), 'secure_url' => Bootstrap::$main->getConfig('protocol') == 'https', 'crop' => true]); } else { $image = new Image($file); $w = $h = 0; if ($imagesize[0] > Bootstrap::$main->getConfig('image_size')) { $w = Bootstrap::$main->getConfig('image_size'); $img = preg_replace("/\\.{$ext}\$/", '-i.' . $ext, $file); $image->min($img, $w, $h, true); $model->url = 'http://' . $_SERVER['HTTP_HOST'] . $this->_media . '/' . preg_replace("/\\.{$ext}\$/", '-i.' . $ext, $name); } else { $model->url = 'http://' . $_SERVER['HTTP_HOST'] . $this->_media . '/' . $name; } $w = $h = 0; if ($imagesize[0] > Bootstrap::$main->getConfig('full_size')) { $w = Bootstrap::$main->getConfig('full_size'); $img = preg_replace("/\\.{$ext}\$/", '-f.' . $ext, $file); $image->min($img, $w, $h, true); $model->full = 'http://' . $_SERVER['HTTP_HOST'] . $this->_media . '/' . preg_replace("/\\.{$ext}\$/", '-f.' . $ext, $name); } else { $model->full = 'http://' . $_SERVER['HTTP_HOST'] . $this->_media . '/' . $name; } $w = $h = 0; if ($image->w() > $image->h()) { $w = Bootstrap::$main->getConfig('thumbnail_size'); } else { $h = Bootstrap::$main->getConfig('thumbnail_size'); } $thmb = preg_replace("/\\.{$ext}\$/", '-t.' . $ext, $file); $image->min($thmb, $w, $h, true); $model->thumbnail = 'http://' . $_SERVER['HTTP_HOST'] . $this->_media . '/' . preg_replace("/\\.{$ext}\$/", '-t.' . $ext, $name); $w = $h = Bootstrap::$main->getConfig('square_size'); $square = preg_replace("/\\.{$ext}\$/", '-s.' . $ext, $file); $image->min($square, $w, $h, false, true); $model->square = 'http://' . $_SERVER['HTTP_HOST'] . $this->_media . '/' . preg_replace("/\\.{$ext}\$/", '-s.' . $ext, $name); } $model->save(); $ret = $model->data(); if ($ctx = Bootstrap::$main->session('image_ctx')) { $model->setLabels($ctx); $ret['labels'] = $model->getLabels(); if (is_array($ctx)) { foreach ($ctx as $k => $e) { if ($k == 'event') { $event = new eventModel($e); if ($event->user == Bootstrap::$main->user['id'] && !$event->img) { $event->img = $model->id; $event->save(); } $model->title = $event->name; $model->save(); } } } } return $this->status($ret); }