Пример #1
0
 public function authenticate($client = null, $code = null, $token = null)
 {
     if ($client === null) {
         $client = $this->client;
     }
     if ($token !== null) {
         $client->token = $token;
     } else {
         if (isset($code)) {
             $client->token = '{"access_token":"mockupToken","token_type":"Bearer","expires_in":3600,"id_token":"mockupIdToken","refresh_token":"mockupRefreshToken","created":' . date_timestamp_get(date_create()) . '}';
             $token = isset($client->token) ? $client->token : null;
         }
     }
     $this->accessToken = $token;
     if (isset($token) && $token) {
         if (isset($client->expiredToken) && $client->expiredToken) {
             $client->token = '{"access_token":"mockupToken","token_type":"Bearer","expires_in":3600,"id_token":"mockupIdToken","refresh_token":"mockupRefreshToken","created":' . date_timestamp_get(date_create()) . '}';
             unset($client->expiredToken);
             $this->accessToken = $client->token;
         }
         return array('access_token' => $this->accessToken);
     } else {
         return array('authUrl' => 'http://mockupauth.url');
     }
 }
Пример #2
0
 function __construct()
 {
     $this->user_data = array(BIRTHDAY => date_timestamp_get(date_create("1985-03-20")), BIRTHPLACE => "QUI!", EMAIL => "*****@*****.**", GENDER => "m", HOBBIES => "porno, siti, soldi", JOB => "nessuno", LIVING_PLACE => "Lì!", NAME => "IO", NICKNAME => "iotransisto", PASSWORD => sha1("cazzi miei!" . sha1("cazzi miei!")), ROLE => "admin", SURNAME => "ESISTO", VISIBLE => true);
     $this->user_data2 = array(BIRTHDAY => date_timestamp_get(date_create("1985-03-20")), BIRTHPLACE => "Lì!", EMAIL => "*****@*****.**", GENDER => "f", HOBBIES => "porno, porno, porno", JOB => "prostituto", LIVING_PLACE => "Là!", NAME => "TU", NICKNAME => "iocoesisto", PASSWORD => sha1("ma fatti i cazzi tuoi" . sha1("ma fatti i cazzi tuoi")), ROLE => "admin", SURNAME => "COESISTI?", VISIBLE => false);
     $this->contact_data = array(NAME => "cellulare", CONTACT => "340xxxxxxx", TYPE => PHONE);
     $this->contact_data2 = array(NAME => "email", CONTACT => "*****@*****.**", TYPE => EMAIL);
 }
 public function remove($id)
 {
     $fav = Favorite::where('StudentID', Auth::user()->StudentID)->where('FavoriteID', $id)->where('favorite', '1')->first();
     $fav->favorite = 0;
     $fav->updated_at = date_timestamp_get(date_create());
     $fav->save();
 }
Пример #4
0
function timeConvert($mysqlTime)
{
    date_default_timezone_set('Europe/Helsinki');
    $date = date_create($mysqlTime);
    $timestamp = date_timestamp_get($date);
    echo $timestamp;
}
Пример #5
0
 /**
  * Constructor
  *
  * @param scalar|array|PayloadInterface $payload
  * @param string $id
  * @param int $timestamp
  * @param float $version
  * @throws 
  */
 public function __construct($payload = null, $id = null, $timestamp = null, $version = 1.0)
 {
     if (!is_null($payload)) {
         if ($payload instanceof PayloadInterface) {
             $this->payload = $payload->getArrayCopy();
         } else {
             if (is_array($payload) || is_scalar($payload)) {
                 $this->payload = $payload;
             } else {
                 throw MessageException::payloadTypeError('Payload must be a scalar value, an array or an instance of PayloadInterface');
             }
         }
     }
     if (is_null($id)) {
         $this->id = uniqid();
     } else {
         $this->id = $id;
     }
     if (is_null($timestamp)) {
         $this->timestamp = date_timestamp_get(date_create());
     } else {
         $this->timestamp = $timestamp;
     }
     $this->version = $version;
 }
Пример #6
0
 public static function store()
 {
     self::check_logged_in(array("asiakas", "tyontekija", "johtaja"));
     $params = $_POST;
     $palvelu = Palvelu::find($params['palvelu_id']);
     $aloitusaika = strtotime($params['paiva'] . ' ' . $params['kellonaika']);
     list($tunnit, $minuutit, $sekunnit) = sscanf($palvelu->kesto, '%d:%d:%d');
     $kesto = new DateInterval(sprintf('PT%dH%dM', $tunnit, $minuutit));
     $lopetusaika = date_timestamp_get(date_add(new DateTime('@' . $aloitusaika), $kesto));
     $attributes = array('asiakas_id' => $params['asiakas_id'], 'palvelu_id' => $params['palvelu_id'], 'tyontekija_id' => $params['tyontekija_id'], 'toimitila_id' => $params['toimitila_id'], 'aloitusaika' => date('Y-m-d H:i', $aloitusaika), 'lopetusaika' => date('Y-m-d H:i', $lopetusaika), 'on_peruutettu' => NULL);
     $varaus = new Varaus($attributes);
     $errors = $varaus->errors();
     // tarkistetaan resurssien ja asiakkaan saatavuus varausajalle
     if (count($errors) == 0) {
         $errors = $varaus->check_overlaps();
     }
     if (count($errors) > 0) {
         $tyontekijat = Tyontekija::all();
         $palvelut = Palvelu::all();
         $toimitilat = Toimitila::all();
         $asiakkaat = Asiakas::all();
         View::make('varaus/varaus_lisaa.html', array('errors' => $errors, 'varaus' => $varaus, 'tyontekijat' => $tyontekijat, 'palvelut' => $palvelut, 'toimitilat' => $toimitilat, 'asiakkaat' => $asiakkaat));
     } else {
         $varaus->save();
         Redirect::to('/', array('message' => 'Varaus tallennettu.'));
     }
 }
 function draw_date($date, $text_center)
 {
     $date_string = date($this->month_year, date_timestamp_get($date));
     $box = imagettfbbox($this->font_size, 0, $this->font, $date_string);
     $text_width = abs($box[4] - $box[0]);
     $text_height = abs($box[5] - $box[1]);
     $text_start = $text_center - $text_width / 2;
     imagettftext($this->im, $this->font_size, 0, $text_start, $this->bottom_line_y + $text_height + $this->tick_height + $this->text_top_padding, $this->textcolor, $this->font, $date_string);
 }
Пример #8
0
function valid_birthday($birthday)
{
    $date = date_create();
    $birthdate = date_create($birthday);
    if (date_timestamp_get($date) <= date_timestamp_get($birthdate)) {
        return 0;
    } else {
        return 1;
    }
}
 /**
  * Serializes the current state.
  * 
  * @param CurrentState  $state        The current state.
  * @param IOutputStream $outputStream The output stream.
  * 
  * @return none
  */
 public function serialize($state, $outputStream)
 {
     $statusLeaseInfo = array('StatusLease' => array('@attributes' => array('ClientId' => $state->getClientId())));
     if ($state instanceof AcquireCurrentState) {
         $statusLeaseInfo['StatusLease']['Acquire'] = array('Incarnation' => $state->getIncarnation(), 'Status' => $state->getStatus(), 'Expiration' => Utilities::isoDate(date_timestamp_get($state->getExpiration())));
     } elseif ($state instanceof ReleaseCurrentState) {
         $statusLeaseInfo['StatusLease']['Release'] = array();
     }
     $currentState = Utilities::serialize($statusLeaseInfo, 'CurrentState');
     fwrite($outputStream, $currentState);
 }
 public function save($id)
 {
     $in = Input::all();
     $post = Post::find($id);
     if (Auth::user()->StudentID == $post->StudentID) {
         $post->message = $in['message'];
         $post->edited = 1;
         $post->updated_at = date_timestamp_get(date_create());
         $post->save();
     }
 }
 public function formatTimeago($value)
 {
     if ($value instanceof DateTime) {
         $value = date_timestamp_get($value);
     } else {
         if (is_string($value)) {
             $value = strtotime($value);
         }
     }
     return $this->inWords(time() - $value);
 }
Пример #12
0
 public function call()
 {
     $app = $this->app;
     $route = $app->request()->getPathInfo();
     if (strpos($route, '/api/') !== false) {
         $res = $app->response();
         $app->response()->headers->set('Content-Type', 'application/json');
         $res->headers->set('X-Api-Version', $this->config['astro']['version']);
         $res->headers->set('X-Timestamp', date_timestamp_get(date_create()));
     }
     $this->next->call();
 }
Пример #13
0
 public function formatTimeago($value)
 {
     if ($value instanceof DateTime) {
         $value = date_timestamp_get($value);
     } else {
         if (is_string($value)) {
             $value = strtotime($value);
         }
     }
     $time = time() - Yii::app()->session['TimeOffSet'];
     return $this->inWords($time - $value);
 }
Пример #14
0
function createToken($ip, $id)
{
    //store id in session
    session_start();
    $_SESSION['user_id'] = $id;
    //convert ip address to base 13
    $cIp = base_convert($ip, 10, 13);
    //convert timestamp to base 25
    $date = date_create();
    $cTime = base_convert(date_timestamp_get($date), 10, 25);
    //convert id to base 11
    $cId = base_convert($id, 10, 11);
    $ipLen = strlen($cIp);
    $timeLen = strlen($cTime);
    $idLen = strlen($cId);
    //normalize lengths
    $add = 12 - $ipLen;
    $os = "";
    for ($i = 0; $i < $add; $i++) {
        $os .= "0";
    }
    $os .= $cIp;
    $cIp = $os;
    $add = 12 - $timeLen;
    $os2 = "";
    for ($i = 0; $i < $add; $i++) {
        $os2 .= "0";
    }
    $os2 .= $cTime;
    $cTime = $os2;
    $add = 12 - $idLen;
    $os3 = "";
    for ($i = 0; $i < $add; $i++) {
        $os3 .= "0";
    }
    $os3 .= $cId;
    $cId = $os3;
    //token prior to zipping
    $preZip .= "{$cIp}";
    $preZip .= "{$cId}";
    $preZip .= "{$cTime}";
    global $zKey;
    //zip pieces
    foreach ($zKey as $val) {
        $token .= substr($preZip, $val, 1);
    }
    //hash token and append to end
    $hash = sha1($token);
    $token .= $hash;
    return $token;
}
Пример #15
0
 /**
  * @access private
  *
  * @param mixed $value
  * @return mixed
  */
 private function applyDateTimeFormat($value)
 {
     $datetime_format = $this->format['datetime'];
     if (empty($datetime_format['format'])) {
         return $value;
     } else {
         $datetime = date_create($value);
         if ($datetime) {
             return strftime($datetime_format['format'], date_timestamp_get($datetime));
         } else {
             return $value;
         }
     }
 }
Пример #16
0
 /**
  * News object constructor that extracts the data from the pseudo-XML scheme
  * used. The format looks like this:
  *
  * <NAME>Schwag</NAME>
  * <DATE>1st january, 1770</DATE>
  * <AUTHOR>Guybrush Threepwood</AUTHOR>
  * <IMG>path/to/treasure.jpg</IMG>
  * <BODY>All I got was this lousy t-shirt!</BODY>
  *
  *
  * FIXME: It currently fails at grabbing the image (see 20020214.xml)
  */
 public function __construct($data, $filename, $processContent = false)
 {
     $vars = array();
     preg_match("/<NAME>(.*)<\\/NAME>.*\t\t# Grab the title\n\t\t\t\t\t<DATE>(.*)<\\/DATE>.*\t\t# Grab the date\n\t\t\t\t\t<AUTHOR>(.*)<\\/AUTHOR>.*\t# Grab the author\n\t\t\t\t\t(?:<IMG>(.*)<\\/IMG>.*)?\t\t# image if set (only once)\n\t\t\t\t\t<BODY>(.*)<\\/BODY>\t\t\t# Grab the body\n\t\t\t\t\t/sUx", $data, $vars);
     if (count($vars) == 6) {
         $this->_title = $processContent ? $this->processText($vars[1]) : $vars[1];
         /* Store the date as an unix timestamp*/
         $this->_date = date_timestamp_get(date_create_from_format("M d, Y", $vars[2]));
         $this->_author = $vars[3];
         $this->_image = $vars[4];
         $this->_content = $processContent ? $this->processText($vars[5]) : $vars[5];
     }
     $this->_filename = basename($filename);
 }
Пример #17
0
 private function createFromDBRow($row)
 {
     $cat = new Category($row[DB::CATEGORY_NAME]);
     $cat->setAuthorId($row[DB::CATEGORY_AUTHOR])->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::CATEGORY_CREATION_DATE])));
     if ($this->loadChildren) {
         $this->loadChildren($cat);
     }
     if ($this->loadParent) {
         $this->loadParentName($cat);
     }
     if ($this->loadAccessCount) {
         $this->getAccessCount($cat);
     }
     return $cat;
 }
Пример #18
0
 public function clean()
 {
     $files = scandir($this->path);
     $current_timestamp = date_timestamp_get(date_create());
     foreach ($files as $key => $file) {
         if ($file[0] != '.') {
             $file_creation_info = explode('_', $file);
             if (isset($file_creation_info[0]) && $file_creation_info[0]) {
                 $file_creation_time = $file_creation_info[0];
                 if ($current_timestamp - $file_creation_time >= $this->storage_time) {
                     unlink($this->path . $file);
                 }
             }
         }
     }
 }
Пример #19
0
 public function test_relative_time()
 {
     $timetag = array('tag' => 'time', 'attributes' => array('is' => 'relative-time'));
     $actual = local::relative_time(time());
     $this->assertTag($timetag + ['content' => 'now'], $actual);
     $onesecbeforenow = time() - 1;
     $actual = local::relative_time($onesecbeforenow);
     $this->assertTag($timetag + ['content' => '1 sec ago'], $actual);
     $relativeto = date_timestamp_get(date_create("01/01/2001"));
     $onesecago = $relativeto - 1;
     $actual = local::relative_time($onesecago, $relativeto);
     $this->assertTag($timetag + ['content' => '1 sec ago'], $actual);
     $oneminago = $relativeto - 60;
     $actual = local::relative_time($oneminago, $relativeto);
     $this->assertTag($timetag + ['content' => '1 min ago'], $actual);
 }
Пример #20
0
 public function indexAction()
 {
     $cookie_name = 'ekalan_mainPageAnimation';
     if (!$this->checksess($cookie_name)) {
         $date = date_create();
         $sess_id = date_timestamp_get($date);
         $this->startsess($cookie_name, $sess_id);
         $mainAnimation = true;
     } else {
         $mainAnimation = false;
     }
     $articleSrv = $this->getServiceLocator()->get('article');
     $articles = $articleSrv->getForHomePublished();
     $manufacturerSrv = $this->getServiceLocator()->get('manufacturer');
     $manufacturers = $manufacturerSrv->getAllManufacturers();
     $testimonialsSrv = $this->getServiceLocator()->get('testimonials');
     $testimonials = $testimonialsSrv->getHomeTestimonials();
     $karuselSrv = $this->getServiceLocator()->get('karusel');
     $karusel_windows = $karuselSrv->getAllKaruselWindows();
     foreach ($manufacturers as $i => $manufacturer) {
         $manufacturers[$i]['url_picture_prepared'] = isset($manufacturer['url_picture']) && $manufacturer['url_picture'] != '' && $manufacturer['url_picture'] != null ? "/assets/application/samples/" . trim($manufacturer['url_picture']) : "/assets/application/img/no_photo.png";
     }
     foreach ($karusel_windows as $key => $wind) {
         $karusel[$key] = $karuselSrv->getKaruselByWind($wind["window_karusel"]);
         foreach ($karusel[$key] as $id => $item) {
             $karusel[$key][$id]['url_photo'] = isset($item['url_photo']) && $item['url_photo'] != '' && $item['url_photo'] != null ? "/assets/application/samples/" . trim($item['url_photo']) : "";
         }
         $karusel[$key]['title_windowkarusel'] = $wind['title_windowkarusel'];
     }
     $folioSrv = $this->getServiceLocator()->get('folio');
     $i = 0;
     foreach ($testimonials as $testimonial) {
         $testimonials[$i]['url_picture'] = isset($testimonial['url_picture']) && $testimonial['url_picture'] != '' && $testimonial['url_picture'] != null && $testimonial['url_picture'] ? "/assets/application/samples/" . trim($testimonial['url_picture']) : "";
         $folio_id = $folioSrv->getFolioIdByTestimonialId($testimonial['id']);
         $testimonials[$i]['url_folio'] = $folio_id ? '/project/' . $folio_id : 0;
         $i += 1;
     }
     $systemSrv = $this->getServiceLocator()->get('system');
     $systems = $systemSrv->getSystem();
     foreach ($systems as $key => $value) {
         $system[$value['name']] = $value['data'];
     }
     $artfirst = $articleSrv->getArtfirstPublishedArticles();
     $artfour = $articleSrv->getArtfourPublishedArticles();
     $arthow = $articleSrv->getArthowPublishedArticles();
     return new ViewModel(array('manufacturers' => $manufacturers, 'testimonials' => $testimonials, 'karusel_windows' => $karusel, 'systems' => $system, 'articles' => $articles, 'artfirst' => $artfirst, 'artfour' => $artfour, 'arthow' => $arthow, 'mainAnimation' => $mainAnimation));
 }
Пример #21
0
 function loadAll($post)
 {
     parent::load($post);
     if (!is_subclass_of($post, "Post")) {
         throw new Exception("Attenzione! Il parametro di ricerca non è un post.");
     }
     $rs = $this->db->execute($s = Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(DB::COMMENT_POST), Operator::EQUAL, intval($post->getID()))), array()), $this->table->getName(), $this);
     $comm = array();
     if ($this->db->num_rows() > 0) {
         while ($row = $this->db->fetch_result()) {
             $c = new Comment($row[DB::COMMENT_COMMENT], intval($row[DB::COMMENT_POST]), intval($row[DB::COMMENT_AUTHOR]));
             $com->setID($row[DB::COMMENT_ID])->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::COMMENT_CREATION_DATE])));
             $comm[] = $com;
         }
     }
     return $post->setComments($comm);
 }
Пример #22
0
 /**
  * {@inheritDoc}
  *
  * - extra: Holds string date incoming from POST
  * - value: Holds datetime information
  */
 public function beforeSave(Field $field, $post)
 {
     if (!empty($post['date']) && !empty($post['format'])) {
         $date = $post['date'];
         $format = $post['format'];
         if ($date = DateToolbox::createFromFormat($format, $date)) {
             $field->set('extra', $post['date']);
         } else {
             $field->metadata->entity->errors($field->name, __d('field', 'Invalid date/time, it must match the the pattern: {0}', $format));
             return false;
         }
         $field->set('value', date_timestamp_get($date));
     } else {
         $field->set('value', null);
     }
     return true;
 }
function getLogin($username, $password)
{
    $user = null;
    $user = querySelect('*', 'user', 'username = "******" AND password = "******"', '0,1');
    if (sizeof($user) != 0) {
        $date = date_create();
        $date = date_timestamp_get($date);
        $session = md5($password . $date);
        $update = queryUpdate('user', 'session = "' . $session . '"', 'username = "******" AND password = "******"');
        if (!$update) {
            $user = null;
        } else {
            $user = querySelect('*', 'user', 'session = "' . $session . '"', '0,1');
        }
    }
    return $user;
}
Пример #24
0
function format_datetime($date)
{
    $today = date_timestamp_get(date_create_from_format("Y-m-d G:i", date("Y-m-d", time()) . " 00:00"));
    $tomorrow = date_timestamp_get(date_create_from_format("Y-m-d G:i", date("Y-m-d", time() + 24 * 60 * 60) . " 00:00"));
    $yesterday = date_timestamp_get(date_create_from_format("Y-m-d G:i", date("Y-m-d", time() - 24 * 60 * 60) . " 00:00"));
    //echo "now = " . time() . "|today = " . $today . "|yest = " . $yesterday . "|tom = " . $tomorrow; //DEBUG
    if ($date >= $today && $date < $tomorrow) {
        $d = "Today " . date("@ g:i a", $date);
    } else {
        if ($date < $today && $date >= $yesterday) {
            $d = "Yesterday " . date("@ g:i a", $date);
        } else {
            $d = date("D jS M Y @ g:i a", $date);
        }
    }
    $d = str_replace("@", "at", $d);
    return $d;
}
Пример #25
0
 function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     $limit = $instance['limit'];
     $incl_jq = $instance['incl_jq'];
     $archives = get_posts('numberposts=-1&limit=orderby=date');
     echo '<li class="widget widget_folding_archives" id="collapsible-archives">';
     echo '<span class="archives-title">' . $title . '</span>';
     $date = 'starting-value';
     foreach ($archives as $single_post) {
         $un_date = date_create($single_post->post_date);
         $month_pos = strrpos($single_post->post_date, '-');
         $new_date = substr($single_post->post_date, 0, $month_pos);
         $url_array = explode('-', $new_date);
         $time_diff = time() - date_timestamp_get($un_date);
         $days_old = floor($time_diff / (60 * 60 * 24));
         if ($days_old <= $limit) {
             if ($new_date !== $date && $date !== 'starting-value') {
                 echo '</ul>';
             }
             if ($new_date !== $date) {
                 echo '<p class="archive-title" >';
                 echo '<a href="/' . $url_array[0] . '/' . $url_array[1] . '/" >';
                 echo date_format($un_date, 'F ') . '<span class="archive-year">';
                 echo date_format($un_date, 'Y') . '</span>';
                 echo '</a></p><ul style="display:none;">';
             }
             echo '<li class="archive_post"><a href="';
             echo get_permalink($single_post->ID);
             echo '">';
             echo $single_post->post_title;
             echo '</a></li>';
         } else {
             break;
         }
         $date = $new_date;
         // Set Date For Next Post
     }
     echo '</ul></li>';
     if ($incl_jq) {
         echo '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" ></script>';
     }
     echo '<script src="/wp-content/plugins/folding-archives/folding.js" type="text/javascript" ></script>';
 }
 public function getEntriesForDate()
 {
     global $wgBlankImgUrl;
     $this->response->addAsset('/resources/wikia/libraries/jquery-ui/jquery-ui-1.8.14.custom.js');
     $this->response->addAsset('extensions/wikia/GamingCalendar/js/GamingCalendarSpecialPage.js');
     $this->response->addAsset('extensions/wikia/GamingCalendar/css/GamingCalendarSpecialPage.scss');
     //@todo move this to init once it supports exceptions
     // Boilerplate special page permissions
     if ($this->wg->user->isBlocked()) {
         $this->setVal('error', wfMsg('blockedtext'));
         return false;
         // skip rendering
     }
     if (!$this->wg->user->isAllowed('specialgamingcalendar')) {
         $this->setVal('error', wfMsg('badaccess-group0'));
         return false;
     }
     if (wfReadOnly() && !wfAutomaticReadOnly()) {
         $this->setVal('error', wfMsg('readonlytext'));
         return false;
     }
     $type = $this->getVal('type');
     $date = $this->getVal('date');
     $year = $this->getVal('year');
     $month = $this->getVal('month');
     $day = $this->getVal('day');
     if (empty($date) && !empty($year) && !empty($month) && !empty($day)) {
         $date = date_timestamp_get(date_create("{$year}-{$month}-{$day}"));
     }
     $entries = array();
     if (!empty($type) && !empty($date) && ctype_digit($date)) {
         $entries = GamingCalendar::loadEntriesForDate($type, $date);
     }
     $typeName = GamingCalendar::getCalendarName($type);
     if (!empty($typeName)) {
         $this->setVal('typeName', $typeName);
     }
     $this->setVal('type', $type);
     $this->setVal('date', $date);
     $this->setVal('entries', $entries);
     $this->setVal('wgBlankImgUrl', $wgBlankImgUrl);
 }
Пример #27
0
 public function eachWeekAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $startDay = $request->query->get('start', '');
     $endDay = $request->query->get('end', '');
     if ($startDay == '' || $endDay == '') {
         $response = new JsonResponse(array('success' => 'fail'));
     } else {
         $sheduleDetails = $em->getRepository('QTUTkbBundle:ScheduleDetail')->findIn($startDay, $endDay);
         $data = array();
         if ($sheduleDetails) {
             foreach ($sheduleDetails as $detail) {
                 $data[] = array('N' => date('N', date_timestamp_get($detail->getDateOccur())), 'period' => $detail->getPeriod(), 'room' => $detail->getRoom()->getId(), 'course' => array('id' => $detail->getCourse()->getId(), 'detail' => $this->getClassesName($detail->getCourse()->getClasses()) . " - " . $detail->getCourse()->getName() . " - " . $this->getInstrutorsName($detail->getCourse()->getInstructors()), 'date' => $detail->getDateOccur(), 'detail_id' => $detail->getId()));
             }
         }
         $response = new JsonResponse(array('success' => 'success', 'data' => $data));
     }
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
 function signin_user($x, $y)
 {
     $hex = hex2bin($x);
     $data = explode("&", $hex);
     $n = explode("=", $data[0]);
     $p = explode("=", $data[1]);
     $usr = str_replace("+", " ", $this->db->escape_str($n[1]));
     $pwd = $this->db->escape_str($p[1]);
     $query = $this->db->query("SELECT * FROM user WHERE User_Username = '******' LIMIT 1");
     if ($query->num_rows() > 0) {
         $row = $query->row_array();
         if ($this->encrypt->decode($row['User_Password']) == $pwd) {
             $query2 = $this->db->query("SELECT * FROM auth_matrix WHERE Auth_ID = '" . $row["Auth_ID"] . "' LIMIT 1");
             $row2 = $query2->row_array();
             $cDate = date_timestamp_get(date_create(mdate('%Y-%m-%d %H:%i:%s', now('Asia/Manila'))));
             $dbDate = date_timestamp_get(date_create($row['User_Current_Time']));
             $diff = $cDate - $dbDate;
             if ($diff > 1) {
                 if ($row["User_Status"] == 0) {
                     if ($y == 'login') {
                         $data_a = array("id" => $row["User_ID"], "username" => $row["User_Username"], "name" => $row["User_Name"], "nickname" => $row["User_Nickname"], "pic" => $row["User_Pic"], "sex" => $row["User_Gender"], "settings" => $row["User_Settings"], "auth_code" => $row2["Auth_Code"], "auth_name" => $row2["Auth_Name"], "state" => "active");
                         $data_e = $this->encrypt->encode(json_encode($data_a));
                         $cookie_data = array('name' => 'DTMSUserData', 'value' => $data_e, 'expire' => '32400');
                         $this->input->set_cookie($cookie_data);
                     } elseif ($y == 'unlock') {
                         $this->user_model->set_cookie_data('state', 'active');
                     }
                     echo "true";
                 } else {
                     echo 'suspended';
                 }
             } else {
                 echo 'forbidden';
             }
         } else {
             echo "false";
         }
     } else {
         echo "false";
     }
 }
Пример #29
0
function format_datetime($date)
{
    $months = array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
    $sh_months = array("Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic");
    $days = array("Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato");
    $sh_days = array("Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab");
    $today = date_timestamp_get(date_create_from_format("Y-m-d G:i", date("Y-m-d", time()) . " 00:00"));
    $tomorrow = date_timestamp_get(date_create_from_format("Y-m-d G:i", date("Y-m-d", time() + 24 * 60 * 60) . " 00:00"));
    $yesterday = date_timestamp_get(date_create_from_format("Y-m-d G:i", date("Y-m-d", time() - 24 * 60 * 60) . " 00:00"));
    //echo "now = " . time() . "|today = " . $today . "|yest = " . $yesterday . "|tom = " . $tomorrow; //DEBUG
    if ($date >= $today && $date < $tomorrow) {
        $d = "Oggi " . date("@ G:i", $date);
    } else {
        if ($date < $today && $date >= $yesterday) {
            $d = "Ieri " . date("@ G:i", $date);
        } else {
            $d = $sh_days[intval(date("w", $date))] . date(" j ", $date) . $sh_months[intval(date("n", $date)) - 1] . date(" Y @ g:i a", $date);
        }
    }
    $d = str_replace("@", "alle", $d);
    return $d;
}
Пример #30
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     if (Session::has('visitordata')) {
         $session_visitor = session('visitordata');
     } else {
         $session_visitor = '';
     }
     //print_r(session());die;
     //Session::put('visitordata', '');
     $card_no = str_random(4) . date_timestamp_get(date_create());
     $arival_date = date('d-m-Y');
     $arival_time = date('H:i');
     $user_role = Auth::user()->role_id;
     $user_locationid = Auth::user()->location_id;
     $visitorlocationid = Auth::user()->location_id;
     $visitorlocation = Location::where('id', '=', $visitorlocationid)->pluck('name');
     if ($user_role == 1) {
         $visitors = DB::table('visitors')->join('locations', 'visitors.location', '=', 'locations.id')->join('visitor_role', 'visitors.id', '=', 'visitor_role.visitor_id')->join('visitor_types', 'visitor_role.role_id', '=', 'visitor_types.id')->join('users', 'users.id', '=', 'visitors.host_name')->get(['visitors.*', 'locations.name', 'visitor_types.name as visitor_type', 'users.name as visitor_host']);
     } else {
         $visitors = DB::table('visitors')->where('location', '=', $user_locationid)->where('arival_date', '=', $arival_date)->join('locations', 'visitors.location', '=', 'locations.id')->join('visitor_role', 'visitors.id', '=', 'visitor_role.visitor_id')->join('visitor_types', 'visitor_role.role_id', '=', 'visitor_types.id')->join('users', 'users.id', '=', 'visitors.host_name')->get(['visitors.*', 'locations.name', 'visitor_types.name as visitor_type', 'users.name as visitor_host']);
     }
     //echo "<pre>"; print_r($visitors);die;
     $visitortypes = VisitorType::all()->toArray();
     $current_visitors = DB::table('visitor_role')->join('visitors', 'visitors.id', '=', 'visitor_role.visitor_id')->where('visitors.status', '=', 1)->where('visitors.arival_date', '=', $arival_date)->get(['visitor_role.role_id']);
     $visitor_counts = array();
     foreach ($visitortypes as $key => $visitortype) {
         $count = 0;
         $visitor_counts[$key]['visitortype'] = $visitortype['name'];
         foreach ($current_visitors as $current_visitor) {
             if ($visitortype['id'] == $current_visitor->role_id) {
                 $count++;
             }
         }
         $visitor_counts[$key]['count'] = $count;
     }
     /*echo "<pre>"; print_r($visitor_counts);die;*/
     $employees = Employee::where('role_id', '=', 5)->get();
     return Response::json(array('visitors' => $visitors, 'visitortypes' => $visitortypes, 'hostnames' => $employees, 'location' => $visitorlocation, 'location_id' => $visitorlocationid, 'card_no' => $card_no, 'arival_date' => $arival_date, 'arival_time' => $arival_time, 'visitor_counts' => $visitor_counts, 'session_visitor' => $session_visitor));
 }