Пример #1
0
 public function get()
 {
     $book = Bootstrap::$main->session('book');
     if (isset($book['event']['id'])) {
         $event = new eventModel($book['event']['id']);
         $book['event']['fb_friend_required'] = 0;
         if (isset($book['event']['fb_friends']) && $book['event']['fb_friends']) {
             $book['event']['fb_friend_required'] = $this->require_fb_friend($event->user, false);
         }
         $book['event']['free_slots'] = $event->getSlots();
         return $this->status($book);
     }
     $this->error(71);
 }
 public function add()
 {
     // get event id
     $event_id = preg_match('/[0-9]+$/', $_REQUEST['text']);
     //get all users
     $userModel = new userMangerModel();
     $userModel->load();
     //create event object
     $event = new eventModel();
     if ($event->add($event_id)) {
         foreach ($userModel->users as $user) {
             $event->inviteUser($user);
         }
         // set message to everything is ok!
         $this->smarty->assign('admin_message', 'everything is ok!');
     } else {
         // set message to event not found / couldn't be added to application
         $this->smarty->assign('admin_message', 'event not found / couldn\'t be added to application');
     }
 }
Пример #3
0
 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;
 }
Пример #4
0
 public function get($country = null)
 {
     if ($this->id && $this->id > 0) {
         $city = $this->city()->get($this->id);
         return $this->status($city, isset($city['id']));
     }
     if (is_null($country)) {
         $geo = Tools::geoip();
         $country = $geo['location']['country'];
     }
     $token = 'cities:' . $country;
     if ($data = Tools::memcache($token)) {
         return $this->status($data, true, 'cities');
     }
     foreach ([$country, null] as $cntr) {
         $cities = $this->city()->country($cntr) ?: [];
         $data = array();
         $event = new eventModel();
         foreach ($cities as $city) {
             $events = $event->search(0, 0, null, $city['lat'], $city['lng'], $city['distance'] ?: 50) ?: [];
             $c = sprintf('%05d', count($events));
             $city['count'] = $c + 0;
             if (count($events)) {
                 $data[$c . '-' . $city['name']] = $city;
             }
         }
         krsort($data);
         $data2 = [];
         foreach ($data as $c) {
             $data2[] = $c;
             if (count($data2) == 3) {
                 break;
             }
         }
         if (count($data2)) {
             break;
         }
     }
     return $this->status(Tools::memcache($token, $data2), true, 'cities');
 }
Пример #5
0
<?php

require_once __DIR__ . '/../base.php';
require_once __DIR__ . '/../../rest/models/eventModel.php';
$event = new eventModel();
$event->purge();
Пример #6
0
     continue;
 }
 $txt = $d;
 if (!isset($session[$d])) {
     $session[$d] = 0;
 }
 if ($d == 'users') {
     $plus = $users - $session[$d];
     $session[$d] = $users;
     $txt .= ' ' . $users;
     if ($plus) {
         $txt .= ' (+' . $plus . ')';
     }
 }
 if ($d == 'moneytransfer') {
     $event = new eventModel();
     $events = $event->getEventsToTransferMoney() ?: [];
     $txt .= ' ' . count($events);
 }
 if ($d == 'events') {
     $plus = $events - $session[$d];
     $session[$d] = $events;
     $txt .= ' ' . $events;
     if ($plus) {
         if ($plus > 0) {
             $plus = "+{$plus}";
         }
         $txt .= ' (' . $plus . ')';
     }
     if (!isset($session['guests'])) {
         $session['guests'] = 0;
Пример #7
0
<?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'];
Пример #8
0
    die(file_get_contents(__DIR__ . '/loading-navi.gif'));
}
if (isset($_GET['lat1']) && isset($_GET['lat2']) && isset($_GET['lng1']) && isset($_GET['lng2'])) {
    require_once __DIR__ . '/../base.php';
    require_once __DIR__ . '/../../rest/models/eventModel.php';
    if ($_GET['lat1'] > $_GET['lat2']) {
        $lat = $_GET['lat1'];
        $_GET['lat1'] = $_GET['lat2'];
        $_GET['lat2'] = $lat;
    }
    if ($_GET['lng1'] > $_GET['lng2']) {
        $lng = $_GET['lng1'];
        $_GET['lng1'] = $_GET['lng2'];
        $_GET['lng2'] = $lng;
    }
    $event = new eventModel();
    $events = $event->map($_GET['lat1'], $_GET['lat2'], $_GET['lng1'], $_GET['lng2'], 0, 0, true) ?: [];
    //mydie($events);
    Header('Content-type: application/json; charset=utf8');
    die(json_encode($events, JSON_NUMERIC_CHECK));
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Jemy Razem</title>
    <style>
      html, body, #map-canvas {
        height: 100%;
Пример #9
0
<?php

require_once __DIR__ . '/../base.php';
require_once __DIR__ . '/../../rest/models/eventModel.php';
require_once __DIR__ . '/../../rest/models/imageModel.php';
require_once __DIR__ . '/../../rest/models/userModel.php';
$event = new eventModel();
$image = new imageModel();
$user = new userModel();
$events = $event->getEventsToPay(24 * 3600) ?: [];
Bootstrap::$main->human_datetime_format();
foreach ($events as $e) {
    $e['img'] = $image->get($e['img']);
    $data = ['guest' => $user->get($e['guest']), 'host' => $user->get($e['user'])];
    Bootstrap::$main->session('time_delta', $data['host']['delta']);
    $data['event'] = $event->get($e['id']);
    $data['event']['img'] = $e['img'];
    echo $data['guest']['firstname'] . ' ' . $data['guest']['lastname'] . ' (' . $data['guest']['email'] . '), ' . $data['guest']['lang'];
    echo ' &raquo; ';
    echo $data['event']['name'] . ' (' . $data['event']['event_start'] . ')';
    echo '<br/>';
    Tools::observe('payment-reminder', $data);
}
Пример #10
0
<?php

require_once __DIR__ . '/../base.php';
require_once __DIR__ . '/../../rest/models/eventModel.php';
require_once __DIR__ . '/../../rest/controllers/eventController.php';
$event = new eventModel();
$events = $event->getEventsAfterDeadlineToCancel();
if (is_array($events)) {
    foreach ($events as $id) {
        $guests = $event->getGuests($id);
        if (!$guests || !count($guests)) {
            continue;
        }
        $e = $event->get($id);
        Bootstrap::$main->user['id'] = $e['user'];
        $eventController = new eventController($id, []);
        $eventController->delete(true);
    }
}
Пример #11
0
        echo $_GET['q'];
    }
    ?>
" placeholder="user: id, email or url" /><input type="submit" value="search"/>
</form>
<?php 
}
?>


<?php 
if ($us) {
    ?>

<?php 
    $event = new eventModel();
    $count = 0 + $event->count(['user' => $us['id']]);
    ?>

<ul id="events">
	<li class="row">
		<div class="col-md-2 col-sm-2">
			<a href="<?php 
    echo Bootstrap::$main->getConfig('app.root') . $us['url'];
    ?>
" target="_blank">
				<img style="width:100px" src="<?php 
    echo $us['photo'];
    ?>
"/>
			</a>
Пример #12
0
                 if (isset($urls[$event['url']])) {
                     continue;
                 }
                 $ul[] = ['class' => 'event', 'url' => $url . $event['url'], 'name' => $event['name'], 'img' => $event['img']['square']];
                 $urls[$event['url']] = true;
             }
         }
         $url .= $user['user']['url'];
         $img_url = $url;
     }
 } elseif ($parts[1]) {
     $eventController = new eventController($parts[1], [], $parts);
     $method = 'get_' . $parts[0];
     $event = $eventController->{$method}();
     if (isset($event['event'])) {
         $event_model = new eventModel();
         $u = explode('/', $event['event']['url']);
         $e = $event_model->find_on_url($u[0], $u[1]);
         $dates = $event_model->get_dates($e['id'], false) ?: [];
         $itemscope = 'Events';
         if (isset($event['event']['rate'])) {
             $rate = $event['event']['rate'];
         }
         $title = $event['event']['name'];
         $pagetitle = $title . ' - ' . $event['event']['city'];
         $description = $event['event']['about'];
         $photo = $event['event']['img']['url'];
         $img = $event['event']['host']['photo'];
         if (isset($event['event']['tags']) && is_array($event['event']['tags'])) {
             $tags = [];
             foreach ($event['event']['tags'] as $t) {
Пример #13
0
require_once __DIR__ . '/../../rest/models/userModel.php';
require_once __DIR__ . '/../../rest/models/imageModel.php';
require_once __DIR__ . '/../../rest/models/guestModel.php';
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;
    }
Пример #14
0
 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);
 }
Пример #15
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();
 }
Пример #16
0
 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();
 }
Пример #17
0
function sitemap_date($t)
{
    return date('c', $t);
}
include __DIR__ . '/locale.php';
$sitemap = [];
$sitemap[] = ['loc' => $url, 'priority' => 1, 'lastmod' => sitemap_date(strtotime(date('Y-m-d')))];
$city = new cityController();
$cities = $city->get($country);
$rate = new rateModel();
if (isset($cities['cities'])) {
    foreach ($cities['cities'] as $city) {
        $sitemap[] = ['loc' => $url . 'events/' . $city['lat'] . '/' . $city['lng'] . '/' . round($city['distance']) . '/' . urlencode($city['name']), 'priority' => 0.9, 'lastmod' => sitemap_date(strtotime(date('Y-m-d')))];
    }
}
$event = new eventModel();
$events = $event->allEventsForCountry($country);
$hosts = [];
foreach ($events as $e) {
    $date = $e['d_change'] ?: strtotime(date('Y-m-d'));
    $reviews = $rate->event_reviews($e['event_id'], true, 1) ?: [];
    if (isset($reviews[0]) && $reviews[0]['d_create'] > $date) {
        $date = $reviews[0]['d_create'];
    }
    $sitemap[] = ['loc' => $url . $e['host_url'] . '/' . $e['event_url'], 'priority' => 0.8, 'lastmod' => sitemap_date($date)];
    if (isset($hosts[$e['host_url']])) {
        $hosts[$e['host_url']] = max($hosts[$e['host_url']], $date);
    } else {
        $hosts[$e['host_url']] = $date;
    }
}