/** * Generate RSS XML with sales rules data * * @return string */ protected function _toHtml() { $storeId = $this->_getStoreId(); $storeModel = $this->_storeManager->getStore($storeId); $websiteId = $storeModel->getWebsiteId(); $customerGroup = $this->_getCustomerGroupId(); $now = date('Y-m-d'); $url = $this->_urlBuilder->getUrl(''); $newUrl = $this->_urlBuilder->getUrl('rss/catalog/salesrule'); $title = __('%1 - Discounts and Coupons', $storeModel->getName()); $lang = $this->_scopeConfig->getValue('general/locale/code', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeModel); /** @var $rssObject \Magento\Rss\Model\Rss */ $rssObject = $this->_rssFactory->create(); $rssObject->_addHeader(array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8', 'language' => $lang)); /** @var $collection \Magento\SalesRule\Model\Resource\Rule\Collection */ $collection = $this->_collectionFactory->create(); $collection->addWebsiteGroupDateFilter($websiteId, $customerGroup, $now)->addFieldToFilter('is_rss', 1)->setOrder('from_date', 'desc'); $collection->load(); /** @var $ruleModel \Magento\SalesRule\Model\Rule */ foreach ($collection as $ruleModel) { $description = '<table><tr>' . '<td style="text-decoration:none;">' . $ruleModel->getDescription() . '<br/>Discount Start Date: ' . $this->formatDate($ruleModel->getFromDate(), 'medium'); if ($ruleModel->getToDate()) { $description .= '<br/>Discount End Date: ' . $this->formatDate($ruleModel->getToDate(), 'medium'); } if ($ruleModel->getCouponCode()) { $description .= '<br/> Coupon Code: ' . $ruleModel->getCouponCode(); } $description .= '</td></tr></table>'; $rssObject->_addEntry(array('title' => $ruleModel->getName(), 'description' => $description, 'link' => $url)); } return $rssObject->createRssXml(); }
/** * @throws \PhpOffice\PhpWord\Exception\Exception * Создание word для юр вопросов */ public static function ur_questions($row) { $user = User::findOne(\Yii::$app->user->identity->id); $file = \Yii::$app->basePath . '/temp/ur_questions/' . $row['qid'] . '.docx'; $template = \Yii::$app->basePath . '/temp/ur_questions/Template.docx'; $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($template); // Variables on different parts of document $row['question'] = str_replace("\n", "<w:br/>", $row['question']); //Для пробелов $templateProcessor->setValue('vopros', $row['question']); $templateProcessor->setValue('date', date("d.m.Y")); $templateProcessor->setValue('ur_name', $row['uname']); $templateProcessor->setValue('ur_ruk', $row['contact_face']); $templateProcessor->setValue('ur_phone', $row['contact_phone']); $templateProcessor->setValue('ur_mail', $row['contact_mail']); $templateProcessor->setValue('ur_region', $row['rname']); //$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header $templateProcessor->saveAs($file); $qf = explode("|", $row['qfiles']); if (!isset($qf[0])) { $qf[0] = $qf; } $mail = \Yii::$app->mail->compose('ur_questions', ['uname' => $row['uname'], 'username' => $user['username'], 'mail' => $user['mail']])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo(\Yii::$app->params['uristEmail'])->setSubject('Юридический вопрос')->attach($file); foreach ($qf as $q) { if ($q != "") { $mail->attach($q); } } $mail->send(); // if($templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx')) { // return true; // }else{ // return false; // } }
public function getkey($actionUrl = null, $mktime = null) { $actionUrl = $this->_getActionUrl($actionUrl); if ($mktime == null) { $lifetime = Centurion_Config_Manager::get('ticket.lifetime'); list($lifetimeValue, $lifetimeUnit) = sscanf($lifetime, '%d%s'); $mktime = new Zend_Date(); switch ($lifetimeUnit) { case 'j': case 'd': $mktime->setHour(0); case 'h': $mktime->setMinute(0); case 'm': default: $mktime->setSecond(0); } } if ($mktime instanceof Zend_Date) { $date = $mktime->toString('YYYYMMdd-HH:mm'); } else { $date = date('Ymd-H:i', $mktime); } $salt = Centurion_Config_Manager::get('ticket.salt'); $ticket = md5($salt . $actionUrl . $date); return $ticket; }
function automacuser($json = false) { global $Settings; // TODO MAC is passed in via uam $mac = DatabaseFunctions::getInstance()->latestMacFromIP(remoteip()); $autoUsername = mactoautousername($mac); // Attempt to create user // $autoCreateGroup = $Settings->getSetting('autocreategroup'); $autoCreatePassword = $Settings->getSetting('autocreatepassword'); $groupSettings = $Settings->getGroup($autoCreateGroup); /* TODO Set at the group level and not in the radcheck table, * requires changes to how DB class works */ if ($autoCreateGroup && strlen($autoUsername) > 0) { // Create user DatabaseFunctions::getInstance()->createUser($autoUsername, $autoCreatePassword, false, false, '--', $groupSettings[$autoCreateGroup]['ExpireAfter'], $autoCreateGroup, "Auto created account for {$mac} at " . date('Ymd H:i:s')); // Users password may not match the autocreatepassword if it's changed. // Should we update the users password or get the users password? DatabaseFunctions::getInstance()->setUserPassword($autoUsername, $autoCreatePassword); // Create CHAP Challenge/Response token $challenge = $_GET['challenge']; $response = chapchallengeresponse($challenge, $autoCreatePassword); $loginURL = uamloginurl($autoUsername, $response); if ($json) { return json_encode(array('username' => $autoUsername, 'challenge' => $challenge, 'response' => $response)); } else { header("Location: {$loginURL}"); return false; } } return false; }
public function getLoggedinDashboard() { $role = Auth::user()->role; if ($role == 'hotel-staff') { $branch_code = $this->getStaffBranch(); $data_room_booked_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->where('branch.branch_code', '=', $branch_code)->where('hotel_rooms.status', '=', 'booked')->count(); $data_room_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->where('branch.branch_code', '=', $branch_code)->where('hotel_rooms.status', '=', 'available')->count(); $data_total_sales = DB::table('sales')->where('branch_code', '=', $branch_code)->sum('sale_value'); $total_client = DB::table('customer')->join('accommodation', 'customer.customer_id', '=', 'accommodation.customer_id')->select('customer.customer_id', 'accommodation.branch_code')->where('accommodation.branch_code', '=', $branch_code)->count(); $data_room = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->select('hotel_rooms.room_code', 'hotel_rooms.branch_code', 'hotel_rooms.price_per_night', 'hotel_rooms.description', 'hotel_rooms.status', 'hotel_rooms.image', 'branch.branch_name', 'branch.address', 'branch.email', 'branch.city')->where('branch.branch_code', '=', $branch_code)->where('hotel_rooms.status', '=', 'available')->take(5)->get(); $data_room_booked = DB::table('accommodation')->join('customer', 'accommodation.customer_id', '=', 'customer.customer_id')->select('customer.fullname', 'accommodation.branch_code', 'accommodation.room_code', 'accommodation.checkin_time', 'accommodation.checkout_time')->where('accommodation.branch_code', '=', $branch_code)->orderBy('checkout_time')->take(5)->get(); $cancelled = DB::table('refund')->where('date', '=', date('y-m-d'))->where('branch_id', '=', $branch_code)->count('refund_id'); } else { DB::setFetchMode(PDO::FETCH_ASSOC); $company_id_logged_user = Auth::user()->comp_id; $data_room_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->where('branch.company_id', '=', $company_id_logged_user)->where('hotel_rooms.status', '=', 'available')->count(); $data_room_booked_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->where('branch.company_id', '=', $company_id_logged_user)->where('hotel_rooms.status', '=', 'booked')->count(); $data_total_sales = DB::table('sales')->where('company_id', '=', Auth::user()->comp_id)->sum('sale_value'); $total_client = DB::table('customer')->select('customer_id')->where('company_id', '=', Auth::user()->comp_id)->count(); $company_id_logged_user = Auth::user()->comp_id; $data_room = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->select('hotel_rooms.room_code', 'hotel_rooms.branch_code', 'hotel_rooms.price_per_night', 'hotel_rooms.description', 'hotel_rooms.status', 'hotel_rooms.image', 'branch.branch_name', 'branch.address', 'branch.email', 'branch.city')->where('branch.company_id', '=', $company_id_logged_user)->where('hotel_rooms.status', '=', 'available')->take(5)->get(); $data_room_booked = DB::table('accommodation')->join('customer', 'accommodation.customer_id', '=', 'customer.customer_id')->select('customer.fullname', 'accommodation.branch_code', 'accommodation.room_code', 'accommodation.checkin_time', 'accommodation.checkout_time')->where('accommodation.comp_id', '=', Auth::user()->comp_id)->orderBy('checkout_time')->take(5)->get(); $cancelled = DB::table('refund')->join('branch', 'refund.branch_id', '=', 'branch.branch_code')->where('branch.company_id', '=', Auth::user()->comp_id)->count('refund_id'); } return View::make('dashboard', array('data' => $data_room_details, 'booked' => $data_room_booked_details, 'sales' => $data_total_sales, 'clients' => $total_client, 'room_details' => $data_room, 'room_booked' => $data_room_booked, 'cancelled' => $cancelled)); }
/** * test if a value is a valid credit card expiration date * * @param string $value the value being tested * @param boolean $empty if field can be empty * @param array params validate parameter values * @param array formvars form var values */ function smarty_validate_criteria_isCCExpDate($value, $empty, &$params, &$formvars) { if (strlen($value) == 0) { return $empty; } if (!preg_match('!^(\\d+)\\D+(\\d+)$!', $value, $_match)) { return false; } $_month = $_match[1]; $_year = $_match[2]; if (strlen($_year) == 2) { $_year = substr(date('Y', time()), 0, 2) . $_year; } $_month = (int) $_month; $_year = (int) $_year; if ($_month < 1 || $_month > 12) { return false; } if (date('Y', time()) > $_year) { return false; } if (date('Y', time()) == $_year && date('m', time()) > $_month) { return false; } return true; }
function popular($skin_dir = 'basic', $pop_cnt = 7, $date_cnt = 3) { global $config, $g5; if (!$skin_dir) { $skin_dir = 'basic'; } $date_gap = date("Y-m-d", G5_SERVER_TIME - $date_cnt * 86400); $sql = " select pp_word, count(*) as cnt from {$g5['popular_table']} where pp_date between '{$date_gap}' and '" . G5_TIME_YMD . "' group by pp_word order by cnt desc, pp_word limit 0, {$pop_cnt} "; $result = sql_query($sql); for ($i = 0; $row = sql_fetch_array($result); $i++) { $list[$i] = $row; // 스크립트등의 실행금지 $list[$i]['pp_word'] = get_text($list[$i]['pp_word']); } ob_start(); if (G5_IS_MOBILE) { $popular_skin_path = G5_MOBILE_PATH . '/' . G5_SKIN_DIR . '/popular/' . $skin_dir; $popular_skin_url = G5_MOBILE_URL . '/' . G5_SKIN_DIR . '/popular/' . $skin_dir; } else { $popular_skin_path = G5_SKIN_PATH . '/popular/' . $skin_dir; $popular_skin_url = G5_SKIN_URL . '/popular/' . $skin_dir; } include_once $popular_skin_path . '/popular.skin.php'; $content = ob_get_contents(); ob_end_clean(); return $content; }
/** * testSend method * * @return void */ public function testSendData() { $email = $this->getMock('CakeEmail', array('message'), array()); $email->from('*****@*****.**', 'CakePHP Test'); $email->returnPath('*****@*****.**', 'CakePHP Return'); $email->to('*****@*****.**', 'CakePHP'); $email->cc(array('*****@*****.**' => 'Mark Story', '*****@*****.**' => 'Juan Basso')); $email->bcc('*****@*****.**'); $email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>'); $email->subject('Foø Bår Béz Foø Bår Béz Foø Bår Béz Foø Bår Béz'); $date = date(DATE_RFC2822); $email->setHeaders(array('X-Mailer' => 'CakePHP Email', 'Date' => $date)); $email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', ''))); $data = "From: CakePHP Test <*****@*****.**>" . PHP_EOL; $data .= "Return-Path: CakePHP Return <*****@*****.**>" . PHP_EOL; $data .= "Cc: Mark Story <*****@*****.**>, Juan Basso <*****@*****.**>" . PHP_EOL; $data .= "Bcc: phpnut@cakephp.org" . PHP_EOL; $data .= "X-Mailer: CakePHP Email" . PHP_EOL; $data .= "Date: " . $date . PHP_EOL; $data .= "Message-ID: <4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>" . PHP_EOL; $data .= "MIME-Version: 1.0" . PHP_EOL; $data .= "Content-Type: text/plain; charset=UTF-8" . PHP_EOL; $data .= "Content-Transfer-Encoding: 8bit"; $subject = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?='; $subject .= "\r\n" . ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?='; $this->MailTransport->expects($this->once())->method('_mail')->with('CakePHP <*****@*****.**>', $subject, implode(PHP_EOL, array('First Line', 'Second Line', '.Third Line', '')), $data, '-f'); $this->MailTransport->send($email); }
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; }
public function grabar_venta($pedido, $cliente, $tipo_documento, $nro_documento, $serie_documento) { $query = "INSERT INTO ventas(ped_id,cli_id,ven_fecha,ven_estado,ven_nrodoc,tipc_id,ven_seriedoc) VALUES ('{$pedido}','{$cliente}','" . date('y-m-d') . "','0','{$nro_documento}','{$tipo_documento}','{$serie_documento}')"; $rs = mysql_query($query); $_SESSION['venta_codigo'] = mysql_insert_id(); return $rs; }
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; }
public function updateNotice($data = array()) { $update = array('TITLE' => trim($data['TITLE']), 'CONTENT' => json_encode($data['CONTENT']), 'START_DATE' => trim($data['START_DATE']), 'END_DATE' => trim($data['END_DATE']), 'IS_SHOW' => trim($data['IS_SHOW']), 'UPDATE_DATE' => date('Y-m-d H:i:s')); $wheres = array('NOTICE_ID' => $data['NOTICE_ID']); $this->db->where($wheres)->update('notices', $update); return true; }
/** * @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; }
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>'; } } }
/** * Now we tell doctrine that before we persist or update we call the updatedTimestamps() function. * * @ORM\PrePersist * @ORM\PreUpdate */ public function updateTimestamps() { $this->setModifiedAt(new \DateTime(date('Y-m-d H:i:s'))); if ($this->getCreatedAt() == null) { $this->setCreatedAt(new \DateTime(date('Y-m-d H:i:s'))); } }
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'); } }
function batch_find_images() { $log = elgg_get_config('mfp_log'); $logtime = elgg_get_config('mfp_logtime'); // only search $options = array('type' => 'object', 'subtype' => 'image', 'limit' => 0); $images = new ElggBatch('elgg_get_entities', $options); $count = 0; $bad_images = 0; $total = elgg_get_entities(array_merge($options, array('count' => true))); file_put_contents($log, "Starting scan of {$total} images" . "\n", FILE_APPEND); foreach ($images as $image) { $count++; // don't use ->exists() because of #5207. if (!is_file($image->getFilenameOnFilestore())) { $bad_images++; $image->mfp_delete_check = $logtime; } if ($count == 1 || !($count % 25)) { $time = date('Y-m-d g:ia'); $message = "Checked {$count} of {$total} images as of {$time}"; file_put_contents($log, $message . "\n", FILE_APPEND); } } $message = '<div class="done"><a href="#" id="elgg-tidypics-broken-images-delete" data-time="' . $logtime . '">Delete ' . $bad_images . ' broken images</a></div>'; file_put_contents($log, $message . "\n", FILE_APPEND); }
/** * 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); }
/** * @return ICC_Ecodes_Model_Downloadable */ public function remainingSerialsReport() { /** added for log tracking by anil 28 jul **/ $currDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); $fileName = date("Y-m-d", Mage::getModel('core/date')->timestamp(time())); Mage::log("Controller Name : Ecode/Downloadable , Action Name : remainingSerialsReport , Start Time : {$currDate}", null, $fileName); /** end **/ $threshold = Mage::getStoreConfig(self::XML_PATH_REPORT_THRESHOLD); $errors = array(); if (!is_numeric($threshold) || $threshold < 0) { $error = "Threshold was not a positive integer."; $errors[] = $error; Mage::log("Error while attempting to run " . __METHOD__ . ". " . $error); } else { $notifications = $this->getCollection()->prepareForRemainingReport($threshold); if ($notifications->count()) { try { $this->sendNotificationEmail($notifications); } catch (Exception $e) { Mage::logException($e); } } } /** added for log tracking by anil 28 jul start **/ $currDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); Mage::log("Controller Name : Ecode/Downloadable , Action Name : remainingSerialsReport , End Time : {$currDate}", null, $fileName); /** end **/ return $this; }
function autocode_on_history() { $kode = ""; $query = "SELECT MAX(`id`) FROM `khusus_kas_bank` WHERE DATE(`tgl_input`) = '" . date("Y-m-d") . "';"; if ($result = $this->runQuery($query)) { $rs = $result->fetch_array(); if ($rs[0] == null) { $kode = "KKB" . date("ymd") . "0001"; } else { $lastCode = substr($rs[0], 9, 4); $newCode = $lastCode + 1; switch (strlen($newCode)) { case 1: $kode = "KKB" . date("ymd") . "000" . $newCode; break; case 2: $kode = "KKB" . date("ymd") . "00" . $newCode; break; case 3: $kode = "KKB" . date("ymd") . "0" . $newCode; break; case 4: $kode = "KKB" . date("ymd") . $newCode; break; } } } return $kode; }
function paginate($term = null, $paginateOptions = array()) { $this->_controller->paginate = array('SearchIndex' => array_merge_recursive(array('conditions' => array(array('SearchIndex.active' => 1), 'or' => array(array('SearchIndex.published' => null), array('SearchIndex.published <= ' => date('Y-m-d H:i:s'))))), $paginateOptions)); if (isset($this->_controller->request->params['named']['type']) && $this->_controller->request->params['named']['type'] != 'All') { $this->_controller->request->data['SearchIndex']['type'] = Sanitize::escape($this->_controller->request->params['named']['type']); $this->_controller->paginate['SearchIndex']['conditions']['model'] = $this->_controller->data['SearchIndex']['type']; } // Add term condition, and sorting if (!$term && isset($this->_controller->request->params['named']['term'])) { $term = $this->_controller->request->params['named']['term']; } if ($term) { $term = Sanitize::escape($term); $this->_controller->request->data['SearchIndex']['term'] = $term; $term = implode(' ', array_map(array($this, 'replace'), preg_split('/[\\s_]/', $term))) . '*'; if ($this->like) { $this->_controller->paginate['SearchIndex']['conditions'][] = array('or' => array("MATCH(data) AGAINST('{$term}')", 'SearchIndex.data LIKE' => "%{$this->_controller->data['SearchIndex']['term']}%")); } else { $this->_controller->paginate['SearchIndex']['conditions'][] = "MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE)"; } $this->_controller->paginate['SearchIndex']['fields'] = "*, MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE) AS score"; if (empty($this->_controller->paginate['SearchIndex']['order'])) { $this->_controller->paginate['SearchIndex']['order'] = "score DESC"; } } return $this->_controller->paginate('SearchIndex'); }
function process($user, $msg) { $this->say("-- " . $msg); switch ($msg) { case "bonjour": $this->send($user->socket, "Wesh bro' !"); break; case "salut": $this->send($user->socket, "Java ?"); break; case "Quel est ton nom ?": $this->send($user->socket, "Steve Diop et toi ?"); break; case "Quel age as-tu ?": $this->send($user->socket, "L'age de glace"); break; case "Date ?": $this->send($user->socket, "Hier on était le ... non je rigole on est aujourd'hui le " . date("Y.m.d")); break; case "Heure ?": $this->send($user->socket, "Il est " . date("H:i:s")); break; case "Merci": $this->send($user->socket, "C'est avec grand plaisir mon petit loubin"); break; case "Aurevoir": $this->send($user->socket, "Hasta la vista baby !"); break; default: $this->send($user->socket, $msg . " : je ne sais pas ce que cela signifie"); break; } }
function uf_print_encabezado_pagina($as_titulo,$ls_periodo,$ls_denban,$ls_ctaban,$ls_dencta,&$io_pdf) { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Function: uf_print_encabezadopagina // Access: private // Arguments: as_titulo // Título del Reporte // io_pdf // Instancia de objeto pdf // Description: función que imprime los encabezados por página // Creado Por: Ing. Nelson Barraez // Fecha Creación: 21/04/2006 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $io_encabezado=$io_pdf->openObject(); $io_pdf->saveState(); $io_pdf->line(50,40,550,40); $io_pdf->addJpegFromFile('../../shared/imagebank/'.$_SESSION["ls_logo"],50,770,$_SESSION["ls_width"],$_SESSION["ls_height"]); // Agregar Logo $li_tm=$io_pdf->getTextWidth(11,$as_titulo); $tm=306-($li_tm/2); $io_pdf->addText($tm,750,11,$as_titulo); // Agregar el título $io_pdf->addText(680,750,10,date("d/m/Y")); // Agregar la Fecha $io_pdf->addText(50,738,10,'<b>Periodo:</b>'.$ls_periodo); // Agregar la Fecha $io_pdf->addText(50,725,10,'<b>Banco:</b>'.$ls_denban); // Agregar la Fecha $io_pdf->addText(50,712,10,'<b>Cuenta:</b>'.$ls_ctaban." ".$ls_dencta); // Agregar la Fecha $io_pdf->restoreState(); $io_pdf->closeObject(); $io_pdf->addObject($io_encabezado,'all'); }// end function uf_print_encabezadopagina
protected function getData($nowPage,$pageSize) {/*{{{*/ $dataList = $this->prepareData($nowPage, $pageSize); $res = array(); foreach ($dataList as $data) { $provinceKey = Area::getProvKeyByName($data['prov']); $tempData = array(); $tempData['item']['key'] = $data['prov'].$data['dname'].'医院'; $tempData['item']['url'] = 'http://www.haodf.com/jibing/'.$data['dkey'].'/yiyuan.htm?province='.$provinceKey; $tempData['item']['showurl'] = 'www.haodf.com'; $tempData['item']['title'] = $data['prov'].$data['dname']."推荐医院_好大夫在线"; $tempData['item']['pagesize'] = rand(58, 62).'K'; $tempData['item']['date'] = date('Y-m-d', time()); $tempData['item']['content1'] = "根据".$data['diseasevote']."位".$data['dname']."患者投票得出的医院排行"; $tempData['item']['link'] = $tempData['item']['url']; foreach ($data['formdata'] as $formData) { $tempData['item'][] = $formData; unset($formData); } $res[] = $tempData; unset($data); } return $res; }/*}}}*/
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; }
/** * Initialize the provider * * @return void */ public function initialize() { $this->options = array_merge($this->defaultConfig, $this->options); date_default_timezone_set($this->options['log.timezone']); // Finally, create a formatter $formatter = new LineFormatter($this->options['log.outputformat'], $this->options['log.dateformat'], false); // Create a new directory $logPath = realpath($this->app->config('bono.base.path')) . '/' . $this->options['log.path']; if (!is_dir($logPath)) { mkdir($logPath, 0755); } // Create a handler $stream = new StreamHandler($logPath . '/' . date($this->options['log.fileformat']) . '.log'); // Set our formatter $stream->setFormatter($formatter); // Create LogWriter $logger = new LogWriter(array('name' => $this->options['log.name'], 'handlers' => array($stream), 'processors' => array(new WebProcessor()))); // Bind our logger to Bono Container $this->app->container->singleton('log', function ($c) { $log = new Log($c['logWriter']); $log->setEnabled($c['settings']['log.enabled']); $log->setLevel($c['settings']['log.level']); $env = $c['environment']; $env['slim.log'] = $log; return $log; }); // Set the writer $this->app->config('log.writer', $logger); }
/** * Saves the given file both in the database and on the hard disk. * @param FileResource $resource the file resource. * @param string $name the new name for the file. * @param string $path the path relative to the base path. * @param string $scenario name of the scenario. * @return File the model. * @throws CException if saving the image fails. */ public function saveModel(FileResource $resource, $name = null, $path = null, $scenario = 'insert') { $model = $this->createModel($scenario); $model->extension = strtolower($resource->getExtension()); $model->filename = $resource->getName(); $model->mimeType = $resource->getMimeType(); $model->byteSize = $resource->getSize(); $model->createdAt = date('Y-m-d H:i:s'); if ($name === null) { $filename = $model->filename; $name = substr($filename, 0, strrpos($filename, '.')); } $model->name = $this->normalizeFilename($name); if ($path !== null) { $model->path = trim($path, '/'); } if (!$model->save()) { throw new CException('Failed to save the file model.'); } $filePath = $this->getBasePath(true) . '/' . $model->getPath(); if (!file_exists($filePath) && !$this->createDirectory($filePath)) { throw new CException('Failed to create the directory for the file.'); } $filePath .= $model->resolveFilename(); if (!$resource->saveAs($filePath)) { throw new CException('Failed to save the file.'); } $model->hash = $model->calculateHash(); $model->save(true, array('hash')); return $model; }
public static function logDBUpdates($query_string, $db_name) { # Adds current query to update log $file_name = "../../local/log_" . $_SESSION['lab_config_id'] . "_updates.sql"; $file_name_revamp = "../../local/log_" . $_SESSION['lab_config_id'] . "_revamp_updates.sql"; $file_handle = null; $file_handle_revamp = null; if (file_exists($file_name)) { $file_handle = fopen($file_name, "a"); } else { $file_handle = fopen($file_name, "w"); fwrite($file_handle, "USE blis_" . $_SESSION['lab_config_id'] . ";\n\n"); } if (file_exists($file_name_revamp)) { $file_handle_revamp = fopen($file_name_revamp, "a"); } else { $file_handle_revamp = fopen($file_name_revamp, "w"); fwrite($file_handle_revamp, "USE blis_revamp;\n\n"); } $timestamp = date("Y-m-d H:i:s"); $log_line = $timestamp . "\t" . $query_string . "\n"; $pos = stripos($query_string, "SELECT"); if ($pos === false) { if ($db_name == "blis_revamp") { fwrite($file_handle_revamp, $log_line); } else { fwrite($file_handle, $log_line); } } fclose($file_handle); fclose($file_handle_revamp); }
/** * Return the IFrame URL generated by parsing the data in the URL field. * * @return string HTML code for the administration interface */ private function getGeneratedUrl() { $patterns = array('/\\{node_id\\}/', '/\\{user_id\\}/', '/\\{last_viewed\\}/'); $current_node = Node::getCurrentNode(); if ($current_node) { $node_id = $current_node->getId(); } else { $node_id = ''; } $current_user = User::getCurrentUser(); if ($current_user) { $user_id = $current_user->getId(); } else { $user_id = ''; } $user_last_viewed_ts = $this->getLastDisplayTimestamp($current_user); if ($user_last_viewed_ts) { $user_last_viewed = date('c', $user_last_viewed_ts); } else { $user_last_viewed = null; } $replacements = array(urlencode($node_id), urlencode($user_id), urlencode($user_last_viewed)); $url = $this->getUrl(); $new_url = preg_replace($patterns, $replacements, $url); return $new_url; }
/** * @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; }