Exemplo n.º 1
4
 public function getDatesBetween($dStart, $dEnd)
 {
     if ($dStart > $dEnd) {
         $var = $dStart;
         $dStart = $dEnd;
         $dEnd = $var;
     }
     $iStart = strtotime($dStart);
     $iEnd = strtotime($dEnd);
     if (false === $iStart || false === $iEnd) {
         return false;
     }
     $aStart = explode('-', $dStart);
     $aEnd = explode('-', $dEnd);
     if (count($aStart) !== 3 || count($aEnd) !== 3) {
         return false;
     }
     if (false === checkdate($aStart[1], $aStart[2], $aStart[0]) || false === checkdate($aEnd[1], $aEnd[2], $aEnd[0]) || $iEnd < $iStart) {
         return false;
     }
     for ($i = $iStart; $i < $iEnd + 86400; $i = strtotime('+1 day', $i)) {
         $sDateToArr = strftime('%Y-%m-%d', $i);
         $sYear = substr($sDateToArr, 0, 4);
         $sMonth = substr($sDateToArr, 5, 2);
         //$aDates[$sYear][$sMonth][]=$sDateToArr;
         $aDates[] = $sDateToArr;
     }
     if (isset($aDates) && !empty($aDates)) {
         return $aDates;
     } else {
         return false;
     }
 }
Exemplo n.º 2
1
function dateDiff($start, $end)
{
    $start_ts = strtotime($start);
    $end_ts = strtotime($end);
    $diff = $end_ts - $start_ts;
    return round($diff / 86400);
}
Exemplo n.º 3
1
 public function collectData(array $param)
 {
     $html = $this->file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
     $count = 0;
     $latest = 1;
     $latest_title = "";
     $latest = $html->find('div.conteneur_page a', 1)->href;
     $latest_title = $html->find('div.conteneur_page img', 0)->title;
     function MalikiExtractContent($url)
     {
         $html2 = $this->file_get_html($url);
         $text = 'http://www.maliki.com/' . $html2->find('img', 0)->src;
         $text = '<img alt="" src="' . $text . '"/><br>' . $html2->find('div.imageetnews', 0)->plaintext;
         return $text;
     }
     $item = new \Item();
     $item->uri = 'http://www.maliki.com/' . $latest;
     $item->title = $latest_title;
     $item->timestamp = time();
     $item->content = MalikiExtractContent($item->uri);
     $this->items[] = $item;
     foreach ($html->find('div.boite_strip') as $element) {
         if (!empty($element->find('a', 0)->href) and $count < 3) {
             $item = new \Item();
             $item->uri = 'http://www.maliki.com/' . $element->find('a', 0)->href;
             $item->title = $element->find('img', 0)->title;
             $item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
             $item->content = MalikiExtractContent($item->uri);
             $this->items[] = $item;
             $count++;
         }
     }
 }
Exemplo n.º 4
1
function SSL_COMPRA_FACTURA($transaccion, $salida = 'enlinea')
{
    $c = sprintf('SELECT procon.`codigo_producto`, procon.`titulo` AS "titulo_contenedor", provar.`descripcion` AS "titulo_variedad", provar.foto, comcon.`codigo_compra`, comcon.`codigo_usuario`, comcon.`codigo_variedad`, FORMAT(comcon.`precio_grabado`,2) AS precio_grabado, FORMAT(comcon.`precio_envio`,2) AS precio_envio, comcon.`direccion_entrega`, comcon.`fecha_entrega`, comcon.`tarjeta_de`, comcon.`tarjeta_para`, comcon.`tarjeta_cuerpo`, comcon.`usuario_notas`, comcon.`transaccion`, comcon.`fecha`, `estado`, `correo_contacto`, `telefono_remitente`, `usuario_notas`, `nombre_t_credito`,`estado_notas` FROM `flores_SSL_compra_contenedor` AS comcon LEFT JOIN `flores_producto_variedad` AS provar USING(codigo_variedad) LEFT JOIN `flores_producto_contenedor` AS procon USING(codigo_producto)  WHERE transaccion="%s"', db_codex($transaccion));
    $r = db_consultar($c);
    if (!mysql_num_rows($r)) {
        echo '<p>Lo sentimos, tal factura no existe</p>';
        return;
    }
    $f = mysql_fetch_assoc($r);
    $buffer = '<style>';
    $buffer .= 'table {border-collapse:collapse;}';
    $buffer .= 'table th{border-top:thin solid #c0c0c0;border-left:thin solid #c0c0c0;border-right:thin solid #c0c0c0;background-color:#eee;}';
    $buffer .= 'table td{border-top:thin solid #c0c0c0;border:1px solid #c0c0c0;}';
    $buffer .= '</style>';
    $buffer .= '<table style="width:100%">';
    $campo = array('Factura' => $f['transaccion'], 'F360' => $f['codigo_producto'] . ':' . $f['codigo_variedad'], 'Producto' => $f['titulo_contenedor'], 'Variedad' => $f['titulo_variedad'], 'Precio' => '$' . $f['precio_grabado'], 'Recargo de envio' => '$' . $f['precio_envio'], 'Total' => '$' . number_format($f['precio_grabado'] + $f['precio_envio'], 2, '.', ','), 'Remitente' => $f['tarjeta_de'], 'Destinatario' => $f['tarjeta_para'], 'Tarjeta' => $f['tarjeta_cuerpo'], 'Enviar a' => $f['direccion_entrega'], 'Fecha pedido' => date('d/m/Y'), 'Fecha de entrega' => date('d/m/Y', strtotime($f['fecha_entrega'])), 'Correo contacto' => $f['correo_contacto'], 'Teléfono remitente' => $f['telefono_remitente'], 'Notas adicionales del comprador' => $f['usuario_notas'] ? $f['usuario_notas'] : '[No especificó nada en especial]');
    foreach ($campo as $clave => $valor) {
        $buffer .= sprintf('<tr><td>%s</td><td style="font-weight:bold">%s</td></tr>', $clave, $valor);
    }
    $buffer .= '</table>';
    switch ($salida) {
        case 'enlinea':
            return array($buffer, $f);
            break;
        case 'pdf':
            $buffer = '<html><body>' . $buffer . '</body></html>';
            require_once 'PHP/dompdf/dompdf_config.inc.php';
            $dompdf = new DOMPDF();
            $dompdf->load_html($buffer);
            //$dompdf->render();
            //$dompdf->stream("factura-$transaccion.pdf");
    }
}
Exemplo n.º 5
1
 function calculateGFRResult()
 {
     $tmpArr = array();
     $tmpArr[] = date('Y-m-d H:i:s');
     //observation time
     $tmpArr[] = 'GFR (CALC)';
     //desc
     $gender = NSDR::populate($this->_patientId . "::com.clearhealth.person.displayGender");
     $crea = NSDR::populate($this->_patientId . "::com.clearhealth.labResults[populate(@description=CREA)]");
     $genderFactor = null;
     $creaValue = null;
     $personAge = null;
     $raceFactor = 1;
     switch ($gender[key($gender)]) {
         case 'M':
             $genderFactor = 1;
             break;
         case 'F':
             $genderFactor = 0.742;
             break;
     }
     if ((int) strtotime($crea['observation_time']) >= strtotime('now - 60 days') && strtolower($crea[key($crea)]['units']) == 'mg/dl') {
         $creaValue = $crea[key($crea)]['value'];
     }
     $person = new Person();
     $person->personId = $this->_patientId;
     $person->populate();
     if ($person->age > 0) {
         $personAge = $person->age;
     }
     $personStat = new PatientStatistics();
     $personStat->personId = $this->_patientId;
     $personStat->populate();
     if ($personStat->race == "AFAM") {
         $raceFactor = 1.21;
     }
     $gfrValue = "INC";
     if ($personAge > 0 && $creaValue > 0) {
         $gfrValue = "" . (int) round(pow($creaValue, -1.154) * pow($personAge, -0.203) * $genderFactor * $raceFactor * 186);
     }
     trigger_error("gfr:: " . $gfrValue, E_USER_NOTICE);
     $tmpArr[] = $gfrValue;
     // lab value
     $tmpArr[] = 'mL/min/1.73 m2';
     //units
     $tmpArr[] = '';
     //ref range
     $tmpArr[] = '';
     //abnormal
     $tmpArr[] = 'F';
     //status
     $tmpArr[] = date('Y-m-d H:i:s') . '::' . '0';
     // observationTime::(boolean)normal; 0 = abnormal, 1 = normal
     $tmpArr[] = '0';
     //sign
     //$this->_calcLabResults[uniqid()] = $tmpArr;
     $this->_calcLabResults[1] = $tmpArr;
     // temporarily set index to one(1) to be able to include in selected lab results
     return $tmpArr;
 }
Exemplo n.º 6
0
 public function execute($competition)
 {
     $flight_size = $competition->flight_size ? $competition->flight_size : Competition::FLIGHT_SIZE_DEFAULT;
     $flight_interval = $competition->flight_time ? $competition->flight_time : Competition::FLIGHT_TIME_DEFAULT;
     $flight_time = strtotime("-" . $flight_interval . " minutes", strtotime($competition->start_date));
     Yii::trace('Flight size=' . $flight_size, 'BuildFlightChrono::execute');
     $count = $flight_size;
     $position = 1;
     $registrations = $competition->getRegistrations()->andWhere(['status' => Registration::STATUS_REGISTERED])->orderBy('created_at');
     foreach ($registrations->each() as $registration) {
         if ($count >= $flight_size) {
             $flight_time = strtotime("+" . $flight_interval . " minutes", strtotime($flight_time));
             $count = 0;
             $flight = new Flight();
             $flight->position = $position++;
             $flight->start_time = $flight_time;
             $flight->start_hole = $competition->start_hole;
             $flight->save();
             $flight->refresh();
         }
         Yii::trace('doing=' . $registration->id . '=' . $flight->id . ' at=' . $flight_time, 'BuildFlightChrono::execute');
         $registration->flight_id = $flight->id;
         $registration->save();
         $count++;
     }
 }
 /**
  * @return Highchart
  */
 public function getWeekWeightGraph()
 {
     $weeksWeight = $this->statisticEntryHelper->calculateWeeks((new \DateTime())->modify('-1 year')->modify('sunday this week'), new \DateTime(), StatisticEntry::WEIGHT);
     $averageWeight = $this->statisticEntryHelper->calculateAverage($weeksWeight);
     $weightRange = $this->statisticEntryHelper->getHighAndLow($averageWeight);
     $roundedWeightRange = array(round($weightRange[0] - 5, -1) - 10, round($weightRange[1] + 5, -1));
     //ignore minus kg, not possible,  range are +- to 10, at 0 its rounded to -10
     $roundedWeightRange[0] < 0 ? $roundedWeightRange[0] = 0 : null;
     $weeksBodyFat = $this->statisticEntryHelper->calculateWeeks((new \DateTime())->modify('-1 year')->modify('sunday this week'), new \DateTime(), StatisticEntry::BODY_FAT);
     $averageBodyFat = $this->statisticEntryHelper->calculateAverage($weeksBodyFat);
     $bodyFatRange = $this->statisticEntryHelper->getHighAndLow($averageBodyFat);
     $weeksMuscleMass = $this->statisticEntryHelper->calculateWeeks((new \DateTime())->modify('-1 year')->modify('sunday this week'), new \DateTime(), StatisticEntry::MUSCLE_MASS);
     $averageMuscleMass = $this->statisticEntryHelper->calculateAverage($weeksMuscleMass);
     $muscleMassRange = $this->statisticEntryHelper->getHighAndLow($averageMuscleMass);
     $combinedRange = array_merge($bodyFatRange, $muscleMassRange);
     $combinedRange = $this->statisticEntryHelper->getHighAndLow($combinedRange);
     $roundedCombinedRange = array(round($combinedRange[0] - 5, -1), round($combinedRange[1] + 5, -1));
     //ignore minus %, not possible
     $roundedCombinedRange[0] < 0 ? $roundedCombinedRange[0] = 0 : null;
     $months = array();
     for ($i = 0; $i <= 52; $i++) {
         $months[52 - $i] = $this->_trans(date("W", strtotime(date('Y-m-01') . " -{$i} weeks")));
     }
     $chart = $this->_populateNewChart($averageWeight, $averageBodyFat, $averageMuscleMass, $roundedCombinedRange, $roundedWeightRange, $months);
     $chart->chart->renderTo('linechartWeekWeight');
     return $chart;
 }
Exemplo n.º 8
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // See if user has been a tobacco user before or simultaneosly to the encounter within two years (24 months)
     $date_array = array();
     foreach ($this->getApplicableEncounters() as $encType) {
         $dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate);
         $date_array = array_merge($date_array, $dates);
     }
     // sort array to get the most recent encounter first
     $date_array = array_unique($date_array);
     rsort($date_array);
     // go through each unique date from most recent
     foreach ($date_array as $date) {
         // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
         $date = date('Y-m-d 23:59:59', strtotime($date));
         $beginMinus24Months = strtotime('-24 month', strtotime($date));
         $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months);
         // this is basically a check to see if the patient is an reported as an active smoker on their last encounter
         if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date)) {
             return true;
         } else {
             if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date)) {
                 return false;
             } else {
                 // nothing reported during this date period, so move on to next encounter
             }
         }
     }
     return false;
 }
Exemplo n.º 9
0
 /**
  * Obtiene el listado de grabaciones por cada sala en un intervalo de fechas
  * @return json
  */
 function getRec()
 {
     $rec = $_POST['sco_id'];
     $records = $this->cliente->getRecordings($rec);
     $begrecord = $_POST['inicio'] == "" ? $_POST['tbegin'] : strtotime($_POST['inicio']);
     $endrecord = $_POST['finald'] == "" ? date('Y-m-d') : $_POST['finald'];
     if (!empty($records['recordings'])) {
         if ($records['recordings']['sco'][0]) {
             $data = $records['recordings']['sco'];
         } else {
             $data[] = $records['recordings']['sco'];
         }
     } else {
         $recData->data[]['name'] = 'Sin registros';
         echo json_encode($recData);
         exit;
     }
     foreach ($data as $key => $value) {
         $acl_id = $value['@attributes']['sco-id'];
         $this->cliente->setPublicRecordings($acl_id);
         $date_created = strtotime(date('Y-m-d', strtotime($value['date-created'])));
         if ($date_created >= $begrecord && $date_created <= strtotime($endrecord)) {
             $recData->data[] = $data[$key];
         }
     }
     echo json_encode($recData);
 }
Exemplo n.º 10
0
 private function execute()
 {
     $this->prepareBaseValues();
     $listingsProducts = $this->getNextListingsProducts();
     if (count($listingsProducts) <= 0) {
         $lastTime = strtotime($this->getLastTimeStartCircle());
         $interval = $this->getMinIntervalBetweenCircles();
         if ($lastTime + $interval > Mage::helper('M2ePro')->getCurrentGmtDate(true)) {
             return;
         }
         $this->setLastListingProductId(0);
         $this->resetLastTimeStartCircle();
         $listingsProducts = $this->getNextListingsProducts();
         if (count($listingsProducts) <= 0) {
             return;
         }
     }
     $tempIndex = 0;
     $totalItems = count($listingsProducts);
     foreach ($listingsProducts as $listingProduct) {
         $this->updateListingsProductChange($listingProduct);
         if (++$tempIndex % 20 == 0) {
             $percentsPerOneItem = self::PERCENTS_INTERVAL / $totalItems;
             $this->_lockItem->setPercents($percentsPerOneItem * $tempIndex);
             $this->_lockItem->activate();
         }
     }
     $listingProduct = array_pop($listingsProducts);
     $this->setLastListingProductId($listingProduct->getId());
 }
 /**
  * @param $main_account_username
  * @param $main_account_password
  * @param $customer_username
  * @param DateTime $date
  * @return int
  * @throws Exception
  */
 public function getTotalUsedCredits($main_account_username, $main_account_password, $customer_username, DateTime $date)
 {
     $totalCreditUsed = 0;
     $this->customer = $customer_username;
     $this->date = $date;
     $this->main_account_username = $main_account_username;
     $this->main_account_password = $main_account_password;
     $this->date = $this->date->add(new DateInterval("P1D"));
     //the api call doesnt include the current date so we move a day ahead
     $dtToday = $this->date->format("Y-m-d");
     $requestString = "https://www.voipinfocenter.com/API/Request.ashx?command=calloverview&username={$this->main_account_username}&password={$this->main_account_password}&customer={$this->customer}&date={$dtToday}%2000:00:00&recordcount=500";
     $curlRes = curl_init($requestString);
     curl_setopt($curlRes, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curlRes, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($curlRes, CURLOPT_SSL_VERIFYHOST, false);
     $requestResult = curl_exec($curlRes);
     $this->date = $this->date->sub(new DateInterval("P1D"));
     //revert date add
     if (is_null($requestResult) || empty($requestResult)) {
         throw new Exception("Empty result from API server");
     }
     $xmlObject = new SimpleXMLElement($requestResult);
     $callsTempContainer = (array) $xmlObject->Calls;
     $callsTempContainer = $callsTempContainer['Call'];
     foreach ($callsTempContainer as $currentCallObj) {
         // if date is equal to date passed
         $parsedDate = strtotime($currentCallObj['StartTime']);
         if ($this->date->format("Y-m-d") === date("Y-m-d", $parsedDate)) {
             $totalCreditUsed += floatval($currentCallObj['Charge']);
         }
     }
     return $totalCreditUsed;
 }
Exemplo n.º 12
0
 private function show_day_information($type, $date)
 {
     $filter = new filter($this->db, $this->output, $this->user);
     $filter->to_output($this->model->table, $this->model->hostnames);
     if (($stats = $this->model->get_day_statistics($type, $date, $filter->hostname, $filter->webserver)) === false) {
         $this->output->add_tag("result", "Database error.");
         return false;
     }
     $graph = new graph($this->output);
     $graph->title = $this->graphs[$type] . " for " . date("l j F Y", strtotime($date));
     $graph->width = 960;
     $graph->height = GRAPH_HEIGHT;
     foreach ($stats as $hour => $count) {
         $graph->add_bar("Hour " . $hour, $count, "hour");
     }
     $graph->to_output();
     if (($stats = $this->model->get_day_information($type, $date, $filter->hostname, $filter->webserver)) === false) {
         $this->output->add_tag("result", "Database error.");
         return false;
     }
     $this->output->open_tag("day", array("hostnames" => show_boolean($this->model->hostnames), "label" => $this->graphs[$type]));
     foreach ($stats as $stat) {
         if ($type == "requests" || $type == "bytes_sent") {
             $stat["count"] = $this->model->readable_number($stat["count"]);
         }
         $this->output->record($stat, "stat");
     }
     $this->output->close_tag();
 }
Exemplo n.º 13
0
 public function index()
 {
     if ($this->open_sign == 0) {
         //未开启活动提示
     }
     $set_id = M('sign_set')->where(array('token' => session('token')))->getField('id');
     // $where 		= array('set_id'=>$set_id);
     $where = array();
     $user_name = $this->_post('user_name', 'htmlspecialchars,trim');
     $sort = $this->_post('sort', 'trim');
     $startdate = strtotime($this->_post('startdate', 'trim'));
     $enddate = strtotime($this->_post('enddate', 'trim'));
     if ($startdate && $enddate) {
         $where['time'] = array(array('gt', $startdate), array('lt', $enddate), 'and');
     }
     if ($user_name) {
         $where['user_name'] = array('like', '%' . $user_name . '%');
     }
     if (empty($sort)) {
         $order = 'time desc';
     } else {
         $order = 'time ' . $sort;
     }
     $count = $this->sign_db->where($where)->count();
     $Page = new Page($count, 12);
     $list = $this->sign_db->where($where)->order($order)->limit($Page->firstRow . ',' . $Page->listRows)->select();
     $this->assign('search', array('startdate' => $startdate, 'enddate' => $enddate, 'sort' => $sort));
     $this->assign('page', $Page->show());
     $this->assign('list', $list);
     $this->assign('listinfo', 1);
     $this->display();
 }
Exemplo n.º 14
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('report/purchased');
     $this->loadModel('report/purchased');
     //Prepare filter config
     $filter_params = array('date_start', 'date_end');
     if (!$this->request->get['date_start']) {
         $this->request->get['date_start'] = dateInt2Display(strtotime('-30 day'));
     }
     if (!$this->request->get['date_end']) {
         $this->request->get['date_end'] = dateInt2Display(time());
     }
     $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params));
     $filter_grid = new AFilter(array('method' => 'post'));
     $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData());
     $total = $this->model_report_purchased->getTotalOrderedProducts($data);
     $response = new stdClass();
     $response->page = $filter_grid->getParam('page');
     $response->total = $filter_grid->calcTotalPages($total);
     $response->records = $total;
     $results = $this->model_report_purchased->getProductPurchasedReport($data);
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $i;
         $response->rows[$i]['cell'] = array($result['name'], $result['model'], $result['quantity'], $this->currency->format($result['total'], $this->config->get('config_currency')));
         $i++;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($response));
 }
Exemplo n.º 15
0
 function is_datetime($date)
 {
     if ($date == date('Y-m-d H:i:s', strtotime($date))) {
         return true;
     }
     return false;
 }
Exemplo n.º 16
0
 public function refresh($force = false)
 {
     if (extension_loaded('curl')) {
         $data = array();
         if ($force) {
             $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'");
         } else {
             $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" . $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'");
         }
         foreach ($query->rows as $result) {
             $data[] = $this->config->get('config_currency') . $result['code'] . '=X';
         }
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($curl, CURLOPT_HEADER, false);
         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
         curl_setopt($curl, CURLOPT_TIMEOUT, 30);
         $content = curl_exec($curl);
         curl_close($curl);
         $lines = explode("\n", trim($content));
         foreach ($lines as $line) {
             $currency = utf8_substr($line, 4, 3);
             $value = utf8_substr($line, 11, 6);
             if ((double) $value) {
                 $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'");
             }
         }
         $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
         $this->cache->delete('currency');
     }
 }
Exemplo n.º 17
0
 /**
  * Constructor.
  *
  * @param Integer $groupId     Project Id
  * @param Integer $weeksNumber Statistics duration in weeks
  *
  * @return Void
  */
 public function __construct($groupId, $weeksNumber)
 {
     $dao = new GitDao();
     // TODO: Optionally include presonal forks in repo list
     $allRepositories = $dao->getProjectRepositoryList($groupId);
     $um = UserManager::instance();
     $user = $um->getCurrentUser();
     $repoFactory = new GitRepositoryFactory($dao, ProjectManager::instance());
     foreach ($allRepositories as $repo) {
         $repository = $repoFactory->getRepositoryById($repo['repository_id']);
         if ($repository->userCanRead($user)) {
             $this->repoList[] = $repository;
         }
     }
     $this->displayChart = false;
     $this->weeksNumber = min($weeksNumber, self::MAX_WEEKSNUMBER);
     // Init some class properties according to 'weeks number' parameter
     $today = $_SERVER['REQUEST_TIME'];
     $startPeriod = strtotime("-{$this->weeksNumber} weeks");
     $weekInSeconds = self::WEEKS_IN_SECONDS;
     for ($i = $startPeriod + $weekInSeconds; $i < $today + $weekInSeconds; $i += $weekInSeconds) {
         $this->dates[] = date('M d', $i);
         $this->weekNum[] = intval(date('W', $i));
         $this->year[] = intval(date('Y', $i));
     }
 }
Exemplo n.º 18
0
 public function updateCurrencies()
 {
     if (extension_loaded('curl')) {
         $data = array();
         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified > '" . date(strtotime('-1 day')) . "'");
         foreach ($query->rows as $result) {
             $data[] = $this->config->get('config_currency') . $result['code'] . '=X';
         }
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $content = curl_exec($ch);
         curl_close($ch);
         $lines = explode("\n", trim($content));
         foreach ($lines as $line) {
             $currency = substr($line, 4, 3);
             $value = substr($line, 11, 6);
             if ((double) $value) {
                 $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = NOW() WHERE code = '" . $this->db->escape($currency) . "'");
             }
         }
         $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = NOW() WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
         $this->cache->delete('currency');
     }
 }
Exemplo n.º 19
0
 public function updated_on()
 {
     if (preg_match('/Last Updated On:(.*?)\\n/', $this->body, $match)) {
         return strtotime($match[1]);
     }
     return null;
 }
Exemplo n.º 20
0
 public function created_on()
 {
     if (preg_match('/Created On :[\\s]+(.*?)\\n/', $this->body, $match)) {
         return strtotime($match[1]);
     }
     return null;
 }
Exemplo n.º 21
0
 function gdlr_print_hotel_availability_item($settings = array())
 {
     $item_id = empty($settings['page-item-id']) ? '' : ' id="' . $settings['page-item-id'] . '" ';
     global $gdlr_spaces, $hotel_option;
     $margin = !empty($settings['margin-bottom']) && $settings['margin-bottom'] != $gdlr_spaces['bottom-blog-item'] ? 'margin-bottom: ' . $settings['margin-bottom'] . ';' : '';
     $margin_style = !empty($margin) ? ' style="' . $margin . '" ' : '';
     $current_date = current_time('Y-m-d');
     $next_date = date('Y-m-d', strtotime($current_date . "+1 days"));
     $value = array('gdlr-check-in' => $current_date, 'gdlr-night' => 1, 'gdlr-check-out' => $next_date, 'gdlr-room-number' => 1, 'gdlr-adult-number' => 1, 'gdlr-children-number' => 0);
     $ret = gdlr_get_item_title($settings);
     $ret .= '<div class="gdlr-hotel-availability-wrapper';
     if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') {
         $ret .= ' gdlr-hotel-branches-enable';
     }
     $ret .= '" ' . $margin_style . $item_id . ' >';
     $ret .= '<form class="gdlr-hotel-availability gdlr-item" id="gdlr-hotel-availability" method="post" action="' . esc_url(add_query_arg(array($hotel_option['booking-slug'] => ''), home_url('/'))) . '" >';
     if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') {
         $ret .= gdlr_get_reservation_branch_combobox(array('title' => __('Hotel Branches', 'gdlr-hotel'), 'slug' => 'gdlr-hotel-branches', 'id' => 'gdlr-hotel-branches', 'value' => ''));
     }
     $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check In', 'gdlr-hotel'), 'slug' => 'gdlr-check-in', 'id' => 'gdlr-check-in', 'value' => $value['gdlr-check-in']));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Night', 'gdlr-hotel'), 'slug' => 'gdlr-night', 'id' => 'gdlr-night', 'value' => $value['gdlr-night']));
     $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check Out', 'gdlr-hotel'), 'slug' => 'gdlr-check-out', 'id' => 'gdlr-check-out', 'value' => $value['gdlr-check-out']));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Adults', 'gdlr-hotel'), 'slug' => 'gdlr-adult-number', 'id' => '', 'value' => $value['gdlr-adult-number'], 'multiple' => true));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Children', 'gdlr-hotel'), 'slug' => 'gdlr-children-number', 'id' => '', 'value' => $value['gdlr-children-number'], 'multiple' => true));
     $ret .= '<div class="gdlr-hotel-availability-submit" >';
     $ret .= '<input type="hidden" name="hotel_data" value="1" >';
     $ret .= '<input type="hidden" name="gdlr-room-number" value="1" />';
     $ret .= '<input type="submit" class="gdlr-reservation-bar-button gdlr-button with-border" value="' . __('Check Availability', 'gdlr-hotel') . '" >';
     $ret .= '</div>';
     $ret .= '<div class="clear"></div>';
     $ret .= '</form>';
     $ret .= '</div>';
     return $ret;
 }
/**
* Prints details about the current Git commit revision
*
* @return void
*/
function PMA_printGitRevision()
{
    if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
        $response = PMA_Response::getInstance();
        $response->isSuccess(false);
        return;
    }
    // load revision data from repo
    $GLOBALS['PMA_Config']->checkGitRevision();
    // if using a remote commit fast-forwarded, link to GitHub
    $commit_hash = substr($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), 0, 7);
    $commit_hash = '<strong title="' . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) . '">' . $commit_hash . '</strong>';
    if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
        $commit_hash = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/commit/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')) . '" target="_blank">' . $commit_hash . '</a>';
    }
    $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
    if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
        $branch = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/tree/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')) . '" target="_blank">' . $branch . '</a>';
    }
    if ($branch !== false) {
        $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
    } else {
        $branch = $commit_hash . ' (' . __('no branch') . ')';
    }
    $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
    $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
    PMA_printListItem(__('Git revision:') . ' ' . $branch . ',<br /> ' . sprintf(__('committed on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null);
}
Exemplo n.º 23
0
 public function save()
 {
     $cover = $this->upload_file('product_cover');
     $download = $this->upload_file('userfile');
     $_POST['cover'] = $cover === '' ? $_POST['cover'] : '/uploads/' . $cover;
     $_POST['download'] = $download == '' ? '' : $download;
     foreach ($_POST as $key => $item) {
         if ($key === 'is_hot' || $key === 'desc' || $key === 'keywords') {
             continue;
         }
         //指定允许空值的字段
         if (empty($_POST[$key])) {
             unset($_POST[$key]);
         }
     }
     if (isset($_POST['id'])) {
         $_POST['ctime'] = strtotime($_POST['ctime']);
         $_POST['mtime'] = time();
         $this->articles_model->update($_POST);
     } else {
         $_POST['ctime'] = time();
         $_POST['mtime'] = time();
         $this->articles_model->insert($_POST);
     }
     echo json_encode(array('success' => true));
 }
function compare_func($a, $b)
{
    // CONVERT $a AND $b to DATE AND TIME using strtotime() function
    $t1 = strtotime($a['date']);
    $t2 = strtotime($b['date']);
    return $t1 - $t2;
}
Exemplo n.º 25
0
 /**
  * List download stats.
  *
  * @param bool|false $Offset
  */
 public function index($Offset = false)
 {
     $this->permission('Garden.Settings.Manage');
     $this->addSideMenu('vstats');
     $this->addJsFile('jquery.gardenmorepager.js');
     $this->title('Vanilla Stats');
     $this->Form->Method = 'get';
     $Offset = is_numeric($Offset) ? $Offset : 0;
     $Limit = 19;
     $this->StatsData = array();
     $Offset--;
     $Year = date('Y');
     $Month = date('m');
     $BaseDate = Gdn_Format::toTimestamp($Year . '-' . str_pad($Month, 2, '0', STR_PAD_LEFT) . '-01 00:00:00');
     for ($i = $Offset; $i <= $Limit; ++$i) {
         $String = "-{$i} month";
         $this->StatsData[] = $this->_getStats(date("Y-m-d 00:00:00", strtotime($String, $BaseDate)));
     }
     $TotalRecords = count($this->StatsData);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->getPager('MorePager', $this);
     $this->Pager->MoreCode = 'More';
     $this->Pager->LessCode = 'Previous';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Wrapper = '<tr %1$s><td colspan="6">%2$s</td></tr>';
     $this->Pager->configure($Offset, $Limit, $TotalRecords, 'vstats/index/%1$s/');
     // Deliver json data if necessary
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->setJson('LessRow', $this->Pager->toString('less'));
         $this->setJson('MoreRow', $this->Pager->toString('more'));
     }
     $this->render();
 }
Exemplo n.º 26
0
    public function updatePost($id, $created, $source, $title)
    {
        $data = array('source' => $source, 'title' => $title);
        // Valid date given (YYYY-MM-DD)?
        if (preg_match('/^\\d{4}.\\d{2}.\\d{2}.+\\d{2}.\\d{2}$/', $created) && strtotime($created)) {
            $data['created'] = $created;
            $initial = $this->db->getRow('SELECT UNIX_TIMESTAMP(created) as created, image, thumb 
				FROM ' . ASAPH_TABLE_POSTS . '
				WHERE id = :1', $id);
            // OK, this sucks hard. If the date changed, we may have to move the thumb and image
            // into another path and make sure to not overwrite any other imagess.
            $initialPath = date('Y/m', $initial['created']);
            $newPath = date('Y/m', strtotime($created));
            if ($initialPath != $newPath && !empty($initial['thumb'])) {
                $newImageDir = ASAPH_PATH . Asaph_Config::$images['imagePath'] . $newPath;
                $newThumbDir = ASAPH_PATH . Asaph_Config::$images['thumbPath'] . $newPath;
                $newImageName = $this->getUniqueFileName($newImageDir, $initial['image']);
                $newThumbName = $this->getUniqueFileName($newThumbDir, $initial['thumb']);
                $initialImagePath = ASAPH_PATH . Asaph_Config::$images['imagePath'] . $initialPath . '/' . $initial['image'];
                $initialThumbPath = ASAPH_PATH . Asaph_Config::$images['thumbPath'] . $initialPath . '/' . $initial['thumb'];
                $newImagePath = $newImageDir . '/' . $newImageName;
                $newThumbPath = $newThumbDir . '/' . $newThumbName;
                $data['image'] = $newImageName;
                $data['thumb'] = $newThumbName;
                if (!$this->mkdirr($newImageDir) || !$this->mkdirr($newThumbDir) || !@rename($initialImagePath, $newImagePath) || !@rename($initialThumbPath, $newThumbPath)) {
                    return false;
                }
            }
        }
        $this->db->updateRow(ASAPH_TABLE_POSTS, array('id' => $id), $data);
        return true;
    }
Exemplo n.º 27
0
function sort_by_size($a, $b)
{
    if ($a['size'] == $b['size']) {
        return 0;
    }
    return strtotime($a['size']) < strtotime($b['size']) ? 1 : -1;
}
Exemplo n.º 28
0
function twitter_time($time)
{
    // Get the number of seconds elapsed since this date
    $delta = time() - strtotime($time);
    if ($delta < 60) {
        return 'minder dan een minuut geleden';
    } else {
        if ($delta < 120) {
            return 'ongeveer een minuut geleden';
        } else {
            if ($delta < 60 * 60) {
                return floor($delta / 60) . ' minuten geleden';
            } else {
                if ($delta < 120 * 60) {
                    return 'ongeveer een uur geleden';
                } else {
                    if ($delta < 24 * 60 * 60) {
                        return floor($delta / 3600) . ' uren geleden';
                    } else {
                        if ($delta < 48 * 60 * 60) {
                            return 'gisteren';
                        } else {
                            return number_format(floor($delta / 86400)) . ' dagen geleden';
                        }
                    }
                }
            }
        }
    }
}
Exemplo n.º 29
0
function order_list_by_time($filter)
{
    //require_once('includes/sql_connection.inc.php');
    global $DBC;
    $result = pg_query_params($DBC, "SELECT \n\t\t\t\t\t\t\t\t\t\t\tdate_trunc(\$1, orderdate) as date_filter, \n\t\t\t\t\t\t\t\t\t\t\tcount(distinct orderid) as numberof_order,\n\t\t\t\t\t\t\t\t\t\t\tcount(distinct customerid) as numberof_customer,\n\t\t\t\t\t\t\t\t\t\t\tcount(distinct prod_id) as numberof_prod,\n\t\t\t\t\t\t\t\t\t\t\tsum(quantity) as quantity_by_time,\n\t\t\t\t\t\t\t\t\t\t\tsum(total) as total_by_time \n\t\t\t\t\t\t\t\t\t\tFROM orders NATURAL JOIN orderlines\n\t\t\t\t\t\t\t\t\t\tGROUP BY date_filter\n\t\t\t\t\t\t\t\t\t\tORDER BY total_by_time DESC", array($filter));
    if ($result) {
        $order_list_by_time = pg_fetch_all($result);
        switch ($filter) {
            case 'day':
                $format = 'D d/M/Y';
                break;
            case 'week':
                $format = 'W M/Y';
                break;
            case 'month':
                $format = 'M/Y';
                break;
            case 'year':
                $format = 'Y';
                break;
            default:
                break;
        }
        for ($i = 0; $i < count($order_list_by_time); $i++) {
            echo '<tr>
	                                                    <td>' . date($format, strtotime($order_list_by_time[$i]['date_filter'])) . '</td>
	                                                    <td>' . $order_list_by_time[$i]['numberof_order'] . '</td>
	                                                    <td>' . $order_list_by_time[$i]['numberof_customer'] . '</td>
	                                                    <td>' . $order_list_by_time[$i]['numberof_prod'] . '</td>                                                    
	                                                    <td>' . $order_list_by_time[$i]['quantity_by_time'] . '</td>
	                                                    <td style="font-weight: bold;" class="price">' . round($order_list_by_time[$i]['total_by_time']) . '</td>
	                                                </tr>';
        }
    }
}
Exemplo n.º 30
-1
 /**
  * @depends testCreateMessage
  */
 function testUpdateMessage($stack)
 {
     try {
         $message = array('title' => $this->getRandom(100), 'message' => $this->getRandom(256), 'deviceType' => 'ios', 'deviceToken' => $this->hexadecimal(64), 'userId' => $this->getRandom(16), 'group' => $this->getRandom(64), 'lang' => 'en', 'deliveryDateTime' => date(DATE_RFC1123, strtotime('15 min')), 'deliveryExpiration' => '1 day', 'badgeIncrement' => false, 'contentAvailable' => false);
         /** @var Model $model */
         $model = $this->getClient()->updateMessage(array_merge(array('pushId' => $stack['PushId']), $message));
         $this->assertNotEmpty($model['result']['updatedDate']);
         usleep(10000);
         $model = $this->getClient()->getMessage(array('pushId' => $stack['PushId']));
         $updated = $model['result'];
         foreach (array('title', 'message', 'deviceType', 'deviceToken', 'userId', 'group', 'lang', 'deliveryExpiration') as $name) {
             $this->assertArrayHasKey($name, $updated);
             $this->assertEquals($message[$name], $updated[$name], sprintf('assertEquals %s', $name));
         }
         $this->assertArrayHasKey('deliveryDateTime', $updated);
         $this->assertEquals($updated['deliveryDateTime'], date('Y-m-d H:i:00', strtotime('15 min')));
         $this->assertArrayHasKey('badgeIncrement', $updated);
         $this->assertEquals(false, $updated['badgeIncrement']);
         $this->assertArrayHasKey('contentAvailable', $updated);
         $this->assertEquals(false, $updated['contentAvailable']);
     } catch (\Guzzle\Http\Exception\BadResponseException $e) {
         $response = $e->getResponse()->json();
         $this->fail(sprintf('Unexpected exception: %s', $response['error_message']));
     } catch (\Exception $e) {
         throw $e;
     }
     return $stack;
 }