本文整理汇总了PHP中Utilities类的典型用法代码示例。如果您正苦于以下问题:PHP Utilities类的具体用法?PHP Utilities怎么用?PHP Utilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public static function index()
{
$count = new Utilities();
$count->countDrinks();
$drinks = Drink::findAll();
View::make('drink/index.html', array('drinks' => $drinks, 'count' => $count));
}
示例2: __call
public function __call($name, $arguments)
{
$file = '';
foreach ($arguments as $key => $argument) {
if (empty($argument)) {
unset($arguments[$key]);
continue;
}
if (!is_array($argument)) {
continue;
}
if (isset($argument['folder'])) {
$file .= $argument['folder'];
unset($arguments[$key]);
}
}
if (!empty($arguments)) {
$filename = array(implode('.', $arguments), $name, self::FILE_EXTENSION);
} else {
$filename = array($name, self::FILE_EXTENSION);
}
$file .= '/' . implode('.', $filename);
if (file_exists(CONTRIB_PATH . self::FOLDER . $file)) {
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Etag: ' . md5(file_get_contents(CONTRIB_PATH . self::FOLDER . $file)));
header('Vary: *');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime(CONTRIB_PATH . self::FOLDER . $file)) . ' GMT');
header('Content-type: ' . Utilities::getMimeType(self::FILE_EXTENSION));
echo file_get_contents(CONTRIB_PATH . self::FOLDER . $file);
exit;
} else {
$this->bye();
}
}
示例3: get
public function get($qid, $class, $student)
{
if ($student != USERNAME) {
Permissions::TA_GATE($qid, $class, USERNAME);
}
$config = Utilities::get_configuration($qid, $class);
$class_dir = Utilities::get_class_base($qid, $class);
$assns = Utilities::get_all_directories($class_dir . "/" . $config->submissions_dir);
$student_submissions = array();
foreach ($assns as $assn) {
$a_dir = $class_dir . "/" . $config->submissions_dir . "/" . $assn;
$all_subs = Utilities::get_all_directories($a_dir);
foreach ($all_subs as $sub) {
$sunetid = Utilities::get_sunetid($sub);
if ($sunetid == $student) {
$test = $a_dir . "/" . $sub;
if (is_dir($test)) {
$student_submissions[] = array("assn" => $assn, "dir" => $sub);
}
}
}
}
//print_r($student_submissions);
$this->smarty->assign("student", $student);
$this->smarty->assign("submissions", $student_submissions);
$this->smarty->display("student.html");
}
示例4: pay
/**
* @method POST
*/
function pay()
{
// get token
$token = Utilities::ValidateJWTToken(apache_request_headers());
// check if token is not null
if ($token != NULL) {
// parse request
parse_str($this->request->data, $request);
$site = Site::GetBySiteId($token->SiteId);
$siteId = $site['SiteId'];
$email = $site['PrimaryEmail'];
$status = 'Active';
$stripe_token = $request['token'];
$plan = $request['plan'];
// set API key
Stripe::setApiKey(STRIPE_SECRET_KEY);
// create a new customer and subscribe them to the plan
$customer = Stripe_Customer::create(array("card" => $stripe_token, "plan" => $plan, "email" => $email));
// get back the id and the end period for the plan
$id = $customer->id;
// get subscription information
$subscription = $customer->subscriptions->data[0];
$subscriptionId = $subscription->id;
$stripe_status = $subscription->status;
$stripe_plan = $subscription->plan->id;
$stripe_planname = $subscription->plan->name;
// subscribe to a plan
Site::Subscribe($siteId, $status, $plan, 'stripe', $subscriptionId, $customerId);
// return a json response
return new Tonic\Response(Tonic\Response::OK);
} else {
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}
示例5: error
public static function error($message, $class = "N/A", $method = "N/A")
{
if (LOG_LEVEL == "ERROR") {
Utilities::checkSize(LOG_FOLDER . "debug.log");
error_log("/r/n[ERROR] " . date("Y-m-d h:i:s") . " - [" . str_pad($class, 20, " ") . "] - [" . str_pad($method, 20, " ") . "] - " . $message . "", 3, LOG_FOLDER . "error.log");
}
}
示例6: create
/**
* Create a new translatable email
*
* @param DBObject $context
* @param string $translation_id
* @param array $variables
*
* @return TranslatableEmail
*/
public static function create($translation_id, $variables)
{
$email = new self();
// Get translation data and variables
$email->translation_id = $translation_id;
$email->variables = array();
if ($variables) {
foreach ($variables as $k => $v) {
// Convert DBObject types to type/id pairs for saving
if ($v instanceof DBObject) {
$v = array('dbobject_type' => get_class($v), 'dbobject_id' => $v->id);
}
$email->variables[$k] = $v;
}
}
// Add meta
$email->created = time();
// Generate token until it is indeed unique
$email->token = Utilities::generateUID(function ($token) {
$statement = DBI::prepare('SELECT * FROM ' . TranslatableEmail::getDBTable() . ' WHERE token = :token');
$statement->execute(array(':token' => $token));
$data = $statement->fetch();
return !$data;
});
$email->save();
return $email;
}
示例7: register
public static function register($device_uuid)
{
$parts = explode(" ", microtime());
$data = array('id' => $parts[1] . round($parts[0] * 1000), 'secret_key' => \Utilities::getRandomCode(64), 'device_uuid' => $device_uuid);
$inserted = static::instance()->createEntity($data)->save();
return $inserted ? static::instance()->getEntity($data['id']) : null;
}
示例8: __construct
function __construct($message, $type)
{
$bootstrap = false;
if (!empty(Utilities::FindKey('BootstrapMessages', $GLOBALS['Config']))) {
$bootstrap = Utilities::FindKey('BootstrapMessages', $GLOBALS['Config']);
}
switch (strtoupper($type)) {
default:
case 'ERR':
case 'ERROR':
$style = 'danger';
break;
case 'SUCC':
case 'SUCCESS':
$style = 'success';
break;
case 'WARN':
case 'WARNING':
$style = 'warning';
break;
case 'INFO':
case 'INFORMATION':
$style = 'info';
break;
}
if ($bootstrap === true) {
$message = '<p class="alert alert-' . $style . '" role="alert">' . $message . '</p>';
}
echo $message;
}
示例9: form
/**
* @method POST
*/
function form()
{
// parse request
parse_str($this->request->data, $request);
$siteUniqId = SITE_UNIQ_ID;
$pageUniqId = $request['pageUniqId'];
$body = $request['body'];
$site = Site::GetBySiteUniqId($siteUniqId);
$page = Page::GetByPageUniqId($pageUniqId);
if ($site != null && $page != null) {
$subject = 'RespondCMS: Form Submission [' . $site['Name'] . ': ' . $page['Name'] . ']';
$content = '<h3>Site Information</h3>' . '<table>' . '<tr>' . '<td style="padding: 5px 25px 5px 0;">Site:</td>' . '<td style="padding: 5px 0">' . $site['Name'] . '</td>' . '</tr>' . '<tr>' . '<td style="padding: 5px 25px 5px 0;">Page:</td>' . '<td style="padding: 5px 0">' . $page['Name'] . '</td>' . '</tr>' . '</table>' . '<h3>Form Details</h3>' . $body;
// send an email
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: ' . $site['PrimaryEmail'] . "\r\n" . 'Reply-To: ' . $site['PrimaryEmail'] . "\r\n";
// sends the email
$to = $site['PrimaryEmail'];
$from = $site['PrimaryEmail'];
$fromName = $site['Name'];
Utilities::SendEmail($to, $from, $fromName, $subject, $content);
// return a successful response (200)
return new Tonic\Response(Tonic\Response::OK);
} else {
// unauthorized access
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}
示例10: getEntryCategories
protected function getEntryCategories($entries)
{
$cat_arr = array();
if (isset($entries[0]['data2'])) {
foreach ($entries as $e) {
$cat_url = strtolower(Utilities::makeUrl($e['data2']));
if (!isset($cat_arr[$cat_url])) {
$cat_arr[$cat_url] = array('category-url' => "{$this->url0}/category/{$cat_url}", 'category-name' => $e['data2'], 'count' => 1);
} else {
$cat_arr[$cat_url]['count'] += 1;
}
}
/*
* Sort the array
*/
usort($cat_arr, "CategorizedGallery::cmp");
/*
* Load the template into a variable
*/
$template = UTILITIES::loadTemplate($this->url0 . '-category.inc');
return UTILITIES::parseTemplate(array_values($cat_arr), $template);
} else {
return NULL;
}
}
示例11: get
function get($request)
{
// admin Only
Utilities::checkAdmin();
$db = Database::obtain();
$response = new Response($request);
$this->tm->smarty->assign('title', 'Admin Infos Tours');
$no_tours = $db->query_first("SELECT count(*) AS no FROM " . TABLE_TOURS);
$no_tours = $no_tours['no'];
$last_page = ceil($no_tours / $this->rows);
//this makes sure the page number isn't below one, or more than our maximum pages
if ($this->page < 1) {
$this->page = 1;
} elseif ($this->page > $last_page) {
$this->page = $last_page;
}
$max = 'LIMIT ' . ($this->page - 1) * $this->rows . ',' . $this->rows;
$tours = $db->fetch_array("SELECT * FROM `" . TABLE_TOURS . "` " . $max);
$this->tm->smarty->assign('lastpage', $last_page);
$this->tm->smarty->assign('pagenum', $this->page);
$em = GeocacheManager::getInstance();
$tours_obj = array();
foreach ($tours as $tour) {
$tours_obj[] = $geocacheManager = $em->fetchTour($tour['webcode']);
}
$this->tm->smarty->assign('tours', $tours_obj);
$body = $this->tm->render('admin_info_tour');
$response->code = Response::OK;
$response->addHeader('Content-type', 'text/html');
$response->body = $body;
return $response;
}
示例12: search
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria();
if (isset($this->city)) {
$this->city = Utilities::getLookupIdByValue(Constants::$city_lookup_code, $this->city);
}
if (isset($this->blood_group)) {
$this->blood_group = Utilities::getLookupIdByValue(Constants::$bloodgrp_lookup_code, $this->blood_group);
}
if (isset($this->area)) {
$this->area = Utilities::getLookupIdByValue(Constants::$area_lookup_code, $this->area);
}
$criteria->compare('request_id', $this->request_id);
$criteria->compare('name', $this->name, true);
$criteria->compare('city', $this->city);
$criteria->compare('state', $this->state);
$criteria->compare('number', $this->number, true);
$criteria->compare('date', $this->date, true);
$criteria->compare('blood_group', $this->blood_group);
$criteria->compare('area', $this->area);
$criteria->compare('status', $this->status, true);
$criteria->compare('remarks', $this->remarks, true);
$criteria->compare('donor', $this->donor);
return new CActiveDataProvider($this, array('criteria' => $criteria));
}
示例13: __construct
public function __construct($title, $message, $code = 500, Exception $previous = null)
{
$this->title = $title;
parent::__construct($message, $code, $previous);
Utilities::statusCode($code, $title);
Utilities::sendHeaders();
}
示例14: __construct
/**
* StringsHandler constructor.
*/
public function __construct()
{
$config = Config::getInstance();
$adapterClass = __NAMESPACE__ . '\\ConfigAdapter\\' . Utilities::formatClassName($config->get('strings_adapter', 'ini'));
$this->adapter = new $adapterClass('strings');
$this->loadStrings();
}
示例15: admin_reset_password
public function admin_reset_password($token = null)
{
if ($this->Auth->loggedIn()) {
$this->redirect('/admin/index');
}
if (!isset($token)) {
if ($this->request->is('post')) {
$user = $this->User->findByEmail($this->request->data['User']['email']);
if (empty($user)) {
$this->Session->setFlash('W bazie nie ma takiego adresu e-mail', 'flash_warning');
$this->redirect('/admin/users/reset_password');
}
$token = Utilities::token();
$this->adminSendMail($this->request->data['User']['email'], 'kAdmin - resetowanie hasła', 'reset_password', array('username' => $user['User']['username'], 'link' => '<a href="' . Router::url('/admin/users/reset_password/' . $token, true) . '">' . Router::url('/admin/users/reset_password/' . $token . $user['User']['id'], true) . '</a>'));
$this->User->id = $user['User']['id'];
$this->User->saveField('token', $token);
$this->set('afterPost', true);
}
} else {
$user = $this->User->findByToken($token);
if (empty($user)) {
throw new NotFoundException('Podany token jest nieprawidłowy.');
}
$pass = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!$'), 0, 6);
$this->User->id = $user['User']['id'];
$this->User->save(array('token' => null, 'password' => $pass), false);
$this->adminSendMail($user['User']['email'], 'kAdmin - resetowanie hasła', 'new_password', array('password' => $pass, 'username' => $user['User']['username']));
$this->set('afterReset', true);
}
}