예제 #1
0
파일: head.php 프로젝트: podstawski/papu
        Bootstrap::$main->user = $u;
        Bootstrap::$main->session('time_delta', $u['delta']);
        echo '<h1><a href="/admin/">' . $u['firstname'] . ' ' . $u['lastname'] . '</a></h1>';
    }
    $session_path = 'gs://' . CloudStorageTools::getDefaultGoogleStorageBucketName() . '/sessions';
} else {
    echo "<h1>Witaj</h1>";
    @mkdir($session_path, 0755);
}
$session_file = "{$session_path}/{$session_token}.sess";
$session = file_exists($session_file) ? unserialize(file_get_contents($session_file)) : [];
$user = new userModel();
$users = $user->count();
$event = new eventModel();
$events = $event->count(['active' => 1, 'd_event_start' => ['>', Bootstrap::$main->now]]);
$guest = new guestModel();
$guests = $guest->join('event', 'events', 'id')->sum('persons', ['active' => 1, 'd_event_start' => ['>', Bootstrap::$main->now], 'd_payment' => ['>', 0], 'd_cancel' => null]);
echo '<div class="menu"><ul>';
if (!isset($menu)) {
    $menu = '';
}
foreach (scandir(dirname(__FILE__)) as $d) {
    if ($d[0] == '.') {
        continue;
    }
    if (!is_dir(__DIR__ . '/' . $d)) {
        continue;
    }
    if ($d == 'lib') {
        continue;
    }
예제 #2
0
 public function delete()
 {
     require_once __DIR__ . '/../models/paymentModel.php';
     require_once __DIR__ . '/../models/imageLabelModel.php';
     require_once __DIR__ . '/../models/rateModel.php';
     require_once __DIR__ . '/../models/guestModel.php';
     require_once __DIR__ . '/../models/tagModel.php';
     $this->requiresLogin();
     if ($this->id && $this->id != Bootstrap::$main->user['id']) {
         $this->requiresLogin(true);
     }
     $user_id = $this->id ?: Bootstrap::$main->user['id'];
     $backup = [];
     $backup['user'] = $this->user($user_id)->data();
     $md5hash = $backup['user']['md5hash'];
     $images = new imageModel();
     $labels = new imageLabelModel();
     $rates = new rateModel();
     $guests = new guestModel();
     $events = new eventModel();
     $tags = new tagModel();
     $payments = new paymentModel();
     $backup['image'] = $images->getUsersImages($user_id) ?: [];
     $backup['imageLabels'] = [];
     foreach ($backup['image'] as $img) {
         $backup['imageLabels'] = array_merge($backup['imageLabels'], $labels->select(['image' => $img['id']]) ?: []);
     }
     $backup['event'] = $events->select(['user' => $user_id]) ?: [];
     $backup['tag'] = $tags->select(['user' => $user_id]) ?: [];
     foreach ($backup['event'] as $event) {
         $backup['tag'] = array_merge($backup['tag'], $tags->select(['event' => $event['id']]) ?: []);
     }
     $backup['rate'] = $rates->select(['user' => $user_id]) ?: [];
     $backup['rate'] = array_merge($backup['rate'], $rates->select(['host' => $user_id]) ?: []);
     $backup['guest'] = $guests->select(['user' => $user_id]) ?: [];
     $backup['payment'] = [];
     foreach ($backup['guest'] as $guest) {
         $backup['payment'] = array_merge($backup['payment'], $payments->select(['guest' => $guest['id']]) ?: []);
     }
     $backup_json = json_encode($backup, JSON_NUMERIC_CHECK);
     $path = 'arch/' . $md5hash . '/' . Bootstrap::$main->human_datetime_format(Bootstrap::$main->now);
     Tools::save($path . '/data.json', $backup_json);
     Tools::save($path . '/img', null, 'img/' . $md5hash);
     Tools::log('remove-user', Bootstrap::$main->user['id']);
     $this->user()->remove();
     if (!$this->id || $this->id == Bootstrap::$main->user['id']) {
         return $this->get_logout();
     }
     return $this->status();
 }
예제 #3
0
파일: index.php 프로젝트: podstawski/papu
<?php

require_once __DIR__ . '/../base.php';
require_once __DIR__ . '/../../rest/models/eventModel.php';
require_once __DIR__ . '/../../rest/models/userModel.php';
require_once __DIR__ . '/../../rest/models/guestModel.php';
require_once __DIR__ . '/../../rest/controllers/eventController.php';
require_once __DIR__ . '/../lib/class/fakturownia.php';
$title = 'Money transfers';
$menu = 'moneytransfer';
include __DIR__ . '/../head.php';
echo "Start analyzing ... <br/>";
$event = new eventModel();
$user = new userModel();
$guest = new guestModel();
$fakturownia = new fakturownia();
$events = $event->getEventsToTransferMoney() ?: [];
$users = [];
$transfers = [];
Bootstrap::$main->human_datetime_format();
foreach ($events as &$e) {
    if (!$e['persons']) {
        continue;
    }
    if (!isset($users[$e['user']])) {
        $users[$e['user']] = $user->get($e['user'], true);
    }
    $e['user'] = $users[$e['user']];
    Bootstrap::$main->session('time_delta', $e['user']['delta']);
    $e['event'] = $event->get($e['id']);
    $e['total'] = $e['persons'] * $e['event']['host_price'];
예제 #4
0
파일: index.php 프로젝트: podstawski/papu
<?php

require_once __DIR__ . '/../base.php';
require_once __DIR__ . '/../../rest/models/guestModel.php';
require_once __DIR__ . '/../../rest/models/paymentModel.php';
require_once __DIR__ . '/../lib/class/payu.php';
$guest = new guestModel();
$payment = new paymentModel();
$timetoapprove = 10 * 24 * 3600;
$from = Bootstrap::$main->now - $timetoapprove;
$payu = new payu();
$payus = $payment->getAllForChannel('payu', $from, 5);
if (is_array($payus)) {
    foreach ($payus as $p) {
        $prc = 100 * (Bootstrap::$main->now - $p['d_payment_create']) / $timetoapprove;
        if ($p['d_cancel']) {
            $r = $payu->cancel_payment($p);
            Tools::log('payu', ['cancel', $r, $p]);
        } elseif ($p['d_deadline'] + 3600 < Bootstrap::$main->now || $prc > 90) {
            $r = $payu->confirm_payment($p);
            Tools::log('payu', ['confirm', $r, $p]);
        }
    }
}
foreach ($guest->getCanceledGuests() ?: [] as $g) {
    $payments = $payment->getForGuest($g['id']);
    if (is_array($payments)) {
        foreach ($payments as $p) {
            $classname = $p['channel'];
            $classfile = __DIR__ . '/../lib/class/' . $classname . '.php';
            if (!file_exists($classfile)) {
예제 #5
0
 protected function reviews($event_id)
 {
     $opt = $this->nav_array(Bootstrap::$main->getConfig('reviews.limit'));
     $rate = new rateModel();
     $reviews = $rate->event_reviews($event_id, true, $opt['limit'], $opt['offset']);
     $usCtrl = new userController();
     if (is_array($reviews)) {
         foreach ($reviews as &$review) {
             $user_id = $review['user'];
             $this->clear_review($review);
             $review['user'] = $usCtrl->public_data($this->user()->get($user_id), true);
         }
     }
     $opt['add'] = 0;
     if (isset(Bootstrap::$main->user['id']) && $opt['offset'] == 0) {
         $guest = new guestModel();
         $rate = new rateModel();
         $guests = $guest->getGuestsForAllEvents($event_id) ?: [];
         foreach ($guests as $g) {
             if ($g['d_event_start'] > Bootstrap::$main->now) {
                 continue;
             }
             if ($rate->user_has_rated_event($g['event'])) {
                 continue;
             }
             $opt['add'] = $g['event'];
             break;
         }
     }
     return array('status' => is_array($reviews), 'options' => $opt, 'reviews' => $reviews);
 }
예제 #6
0
파일: Tools.php 프로젝트: podstawski/papu
 public static function userHasAccessToEvent($event, $user = null, $rewrite = false)
 {
     if (is_null($user)) {
         $user = Bootstrap::$main->user['id'];
     }
     $token = "ue:{$user}:{$event}";
     if (!$rewrite && ($r = self::memcache($token))) {
         return $r['ret'];
     }
     require_once __DIR__ . '/../models/eventModel.php';
     $model = new eventModel($event);
     if (!$model->id) {
         return false;
     }
     if ($model->user == $user) {
         self::memcache($token, ['ret' => true]);
         return true;
     }
     require_once __DIR__ . '/../models/guestModel.php';
     $guest = new guestModel();
     $guests = $guest->getGuests($event) ?: [];
     foreach ($guests as $g) {
         if ($g['user'] == $user) {
             self::memcache($token, ['ret' => true]);
             return true;
         }
     }
     self::memcache($token, ['ret' => false]);
     return false;
 }
예제 #7
0
 protected function paid(paymentModel $payment, $amount)
 {
     if (0.9 * $payment->amount < $amount) {
         $image = new imageModel();
         $guest = new guestModel($payment->guest);
         if ($guest->d_payment) {
             return;
         }
         $guest->d_payment = Bootstrap::$main->now;
         $guest->save();
         $e = $this->event()->get($guest->event);
         Tools::userHasAccessToEvent($guest->event, $guest->user, true);
         $data = [];
         $data['event'] = $this->event()->data();
         $user = new userModel($data['event']['user']);
         $data['host'] = $user->data();
         Bootstrap::$main->session('time_delta', $user->delta);
         Bootstrap::$main->human_datetime_format();
         $data['event'] = $this->event()->get($guest->event);
         $data['event']['img'] = $image->get($data['event']['img']);
         $user->get($guest->user);
         $data['guest'] = $user->data();
         $data['data'] = $guest->data();
         $data['payment'] = $payment->data();
         if (isset($data['payment']['notify'])) {
             $data['notify'] = json_decode($data['payment']['notify'], true);
         }
         $ics = Ics::invitation($e, $data['host'], $data['guest'], $e['create'], $guest->create);
         Tools::observe('event-paid-to-host', $data);
         Tools::observe('event-paid-to-guest', $data, [['invite.ics' => $ics]]);
         Tools::log('guest', $data);
         $eventController = new eventController();
         $eventController->recalculate_fullhouse($guest->event);
     }
 }
예제 #8
0
파일: index.php 프로젝트: podstawski/papu
if (isset($_GET['offset']) || isset($_GET['userid'])) {
    if (isset($_SERVER['SERVER_SOFTWARE']) && strstr(strtolower($_SERVER['SERVER_SOFTWARE']), 'engine')) {
        require_once 'google/appengine/api/users/User.php';
        require_once 'google/appengine/api/users/UserService.php';
        $mail = UserService::getCurrentUser()->getNickname();
        $user = new userModel();
        $u = $user->find_one_by_email(strtolower($mail));
        if (isset($u['id'])) {
            Bootstrap::$main->session('time_delta', $u['delta']);
        }
    }
    $limit = 10;
    $event = new eventModel();
    $image = new imageModel();
    $user = new userModel();
    $guest = new guestModel();
    if (isset($_GET['userid'])) {
        $events = $event->select(['user' => $_GET['userid']], 'd_event_start') ?: [];
    } else {
        $events = $event->select(['active' => 1, 'd_event_start' => ['>', Bootstrap::$main->now]], 'd_event_start', $limit, $_GET['offset']) ?: [];
    }
    foreach ($events as &$e) {
        $e['user'] = $user->get($e['user']);
        $e['img'] = $image->get($e['img']);
        $e['link'] = Bootstrap::$main->getConfig('app.root') . $e['user']['url'] . '/' . $e['url'];
        $e['start'] = Bootstrap::$main->human_datetime_format($e['d_event_start']);
        $e['guests'] = $guest->getGuestCount($e['id']) ?: 0;
    }
    header('Content-type: application/json; charset=utf8');
    die(json_encode($events, JSON_NUMERIC_CHECK));
}
예제 #9
0
 public function getSlots($id = null)
 {
     if (is_null($id)) {
         $id = $this->id;
     } elseif ($id) {
         $this->get($id);
     }
     if (!$id) {
         return false;
     }
     if ($this->max_guests == 10) {
         return 10;
     }
     $guest = new guestModel();
     return $this->max_guests - $guest->getGuestCount($id);
 }