コード例 #1
0
ファイル: bzwbk.php プロジェクト: podstawski/papu
 public function complete($file)
 {
     if (!count($this->tab)) {
         return;
     }
     foreach ($this->tab as $account => $t) {
         $this->wbk .= '1|' . self::account . '|' . $account . '|' . substr($t['name'], 0, 40);
         $this->wbk .= '|' . substr($t['city'], 0, 40) . '|' . substr($t['address'], 0, 40) . '|' . substr($t['postal'], 0, 6);
         $this->wbk .= '|' . $t['total'] . '|1|JemyRazem:' . implode(',', $t['events']) . '||';
         $this->wbk .= "\r\n";
         echo $t['total'] . ' &raquo; ' . $account . ' (' . $t['name'] . ')' . '<br/>';
     }
     $wbk = iconv('UTF-8', 'Windows-1250', $this->wbk);
     foreach ($this->events_ids as $id => $timestamp) {
         $event = new eventModel($id);
         $event->d_transfer = $timestamp;
         $event->save();
     }
     Tools::save($file, $wbk);
     return $wbk;
 }
コード例 #2
0
ファイル: eventController.php プロジェクト: podstawski/papu
 public function delete($auto = false)
 {
     $this->requiresLogin();
     $event = $this->event()->get(0 + $this->id);
     if (!isset($event['user']) || $event['user'] != Bootstrap::$main->user['id']) {
         return $this->error(19);
     }
     $model = new eventModel($event);
     if (!$model->getGuests() && count($model->get_dates($model->id, false)) == 1) {
         $model->remove();
         return $this->status();
     } elseif (!$auto && $model->d_event_start < Bootstrap::$main->now) {
         return $this->error(60);
     } else {
         $guests = $model->getGuests();
         $guestModel = new guestModel();
         $otoken = $auto ? 'auto-cancel' : 'host-cancel';
         Bootstrap::$main->human_datetime_format();
         $event = $this->event()->get(0 + $this->id);
         $host = $this->user()->get($event['user']);
         if (is_array($guests)) {
             foreach ($guests as $guest) {
                 $guestModel->get($guest['guest_id']);
                 $guestModel->cancel_reason = $this->data('reason');
                 $guestModel->d_cancel = Bootstrap::$main->now;
                 $guestModel->canceler = Bootstrap::$main->user['id'];
                 $guestModel->save();
                 $ics = Ics::cancelation($event, $host, $guest, $event['create'], $event['change']);
                 $data = $guestModel->data();
                 $data['event'] = $event;
                 $data['guest'] = $guest;
                 $data['host'] = $host;
                 if ($guestModel->d_payment) {
                     Tools::observe($otoken, $data, [['cancel.ics' => $ics]]);
                 }
             }
         }
         $model->active = -1;
         $model->save();
         Tools::log('event-' . $otoken, ['event' => $model->data(), 'guests' => $guests]);
     }
     return $this->status();
 }
コード例 #3
0
ファイル: imageController.php プロジェクト: podstawski/papu
 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);
 }