License: MIT Output class
 public function AlbumChart($uri)
 {
     $log = new Logger("./log.txt");
     $request = new ImgRequest($uri);
     if ($request->isMalformed()) {
         $log->logGeneration($request, $hostid, true);
         $log->logString("   ERROR: " . $request->getMalformedString());
         die($request->getMalformedString() . (SITE != '' ? "<br />Please see " . SITE . " for further help" : ""));
     }
     if ($request->getCharttype() == "group") {
         $log->logGeneration($request, $hostid, true);
         $log->logString("   ERROR: Groupcharts disabled");
         die("Groupcharts are no longer supported!");
     }
     $userfeed = new UserFeed($request->getRawusername(), $request);
     $albumlist = new AlbumList();
     $i = 0;
     while (($album = $userfeed->getNextItem()) && $i < $request->getCount()) {
         $albumfeed = new AlbumFeed($album);
         if (!$albumfeed->isValid()) {
             continue;
         }
         $albumlist->addItem($albumfeed->getImageUrl());
         unset($albumfeed);
         $i++;
     }
     $image = new ImgGenerator($albumlist, $request);
     $log->logGeneration($request);
     $output = new Output($image, $request);
     if ($output->getFileExists()) {
         $log->logString("   WARNING: File Existed!");
     }
 }
Example #2
0
/**
 * This file is a part of MyWebSQL package
 *
 * @file:      modules/download.php
 * @author     Samnan ur Rehman
 * @copyright  (c) 2008-2012 Samnan ur Rehman
 * @web        http://mywebsql.net
 * @license    http://mywebsql.net/license
 */
function processRequest(&$db)
{
    if (!ini_get('safe_mode')) {
        set_time_limit(0);
    }
    Session::close();
    switch ($_REQUEST['id']) {
        case 'backup':
            include_once BASE_PATH . "/config/backups.php";
            $compression = v($_REQUEST['compression']);
            $file = get_backup_filename($compression);
            include_once BASE_PATH . "/lib/output.php";
            $output = new Output($file, $compression);
            $message = '<div class="message ui-state-highlight">' . __('Database backup successfully created') . '</div>';
            if ($output->is_valid()) {
                downloadDatabase($db, false);
                $output->end();
            } else {
                $message = '<div class="error ui-state-highlight">' . __('Failed to create database backup') . '</div>';
            }
            echo view('backup', array('MESSAGE' => $message), $db->getObjectList());
            break;
        case 'exportres':
            downloadResults($db);
            break;
        case 'exporttbl':
            downloadTable($db, $_REQUEST['name']);
            break;
        case 'export':
            downloadDatabase($db);
            break;
    }
}
Example #3
0
 /**
  * @param Output    $output
  * @param Exception $e
  */
 public function renderForConsole(Output $output, Exception $e)
 {
     if (\Norma\App::$debug) {
         $output->setVerbosity(Output::VERBOSITY_DEBUG);
     }
     (new Console())->renderException($e, $output);
 }
Example #4
0
 /**
  * @param $string
  * @return mixed
  */
 public function write($string)
 {
     $time = microtime(true);
     if ($time - $this->lastWriteTime > $this->threshold) {
         $this->writer->write($string);
         $this->lastWriteTime = $time;
     }
 }
Example #5
0
 function id($id)
 {
     $OUTPUT = new Output();
     // save to array of ids that have been looked up thus far
     // look up permissions and check if user is a member of any groups that have permissions
     $OUTPUT->error(3, "Insufficient Document Level Privleges");
     // if document does not exist in this collection, add it to the collection
 }
Example #6
0
 private function permission($rule = 0, $permission = null)
 {
     $OUTPUT = new Output();
     if ($rule > 1 && $this->role < $rule) {
         // Something About the logic here is not working.
         if (!is_null($permission) && is_array($this->permissions)) {
             if (!in_array($permission, $this->permissions)) {
                 $OUTPUT->error(1, "Insufficient Priveleges");
             }
         } else {
             $OUTPUT->error(1, "Insufficient Priveleges");
         }
     }
 }
Example #7
0
 function __construct($id = null)
 {
     if (!is_null($id)) {
         if ($this->valid_id($id)) {
             session_id($id);
         } else {
             $OUTPUT = new Output();
             $OUTPUT->error(2, "Session_id is invalid");
         }
     }
     if (!$this->session_active()) {
         session_start();
     }
     $this->id = session_id();
 }
 private function addMultipleErrors($description, $file, array $lines)
 {
     $this->foundError = true;
     foreach ($lines as $line) {
         $this->output->addError($description, $file, $line);
     }
 }
Example #9
0
    public function action_index() {
        $menuitems = "";
                $fkey = 0;
        foreach ($this->items as $item) {
            $text = $type = $noajax = $picture = $right = '';
            extract($item);
            //echo $type."_".$right;
            if ($this->parent) {
                $righttype = get_class($this->parent) . '_' . $type;
            } else {
                $righttype = $type;
            }
            if ($right and !Auth::getInstance()->getRights($righttype,'view'))
                continue;

            if ($type == "newline") {
                //$menuitems .= "</tr><tr>";
            } else {
                $uri = new UriConstructor();
                $uri->clear();
                Output::assign('hotkey', $fkey++<11?"Ctrl + f{$fkey }":"");
                Output::assign('text',$text);
                Output::assign('hyphertext',hypher::addhypher($text));
                Output::assign('ajax',($item[noajax]?'':"data-silent='{$this->parent->getMainTarget()}' legotarget='{$this->parent->getName()}'"));
                Output::assign('type',$type);
                Output::assign('url',$uri->set($this->parent->getName(),$type)->url());
                Output::assign('selected',($this->parent->getAction()==$type?" menu-item-sel":""));
                Output::assign('picture', (empty($picture) ? "" : "style='background-image: URL(\"/picture/{$picture}\");'"));
                $menuitems .= $this->fetch('menu_item.tpl');
            }
        }
        Output::assign('menuitems',$menuitems);
        return $this->fetch('menu.tpl');
    }
Example #10
0
File: rest.php Project: ralf57/fuel
	protected function response($data = array(), $http_code = 200)
	{
   		if (empty($data))
		{
			\Output::$status = 404;
			return;
		}

		\Output::$status = $http_code;

		// If the format method exists, call and return the output in that format
		if (method_exists('Controller_Rest', '_format_'.$this->request->format))
		{
			// Set the correct format header
			\Output::set_header('Content-Type', $this->_supported_formats[$this->request->format]);

			$this->output = $this->{'_format_'.$this->request->format}($data);
		}

		// Format not supported, output directly
		else
		{
			$this->output = (string) $data;
		}
	}
Example #11
0
 public function postIndex()
 {
     $input = Input::only('first_name', 'last_name', 'email', 'username', 'password', 'domain_id');
     $domain_id = Cookie::get('domain_hash') ? Cookie::get('domain_hash') : 'NULL';
     $rules = array('first_name' => 'required|min:1', 'email' => 'required|email|unique:users,email,NULL,id,deleted_at,NULL,domain_id,' . $domain_id, 'username' => 'required|min:3|must_alpha_num|unique:users,username,NULL,id,deleted_at,NULL,domain_id,' . $domain_id, 'password' => 'required|min:6');
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         return Output::push(array('path' => 'register', 'errors' => $v, 'input' => TRUE));
     }
     $profile = new Profile(array('first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'website' => ''));
     $profile->save();
     $user = new User(array('domain_id' => Cookie::get('domain_hash') ? Cookie::get('domain_hash') : NULL, 'email' => $input['email'], 'username' => $input['username'], 'password' => Hash::make($input['password']), 'status' => Cookie::get('domain_hash') ? 4 : 3));
     $user->profile()->associate($profile);
     $user->save();
     if ($user->id) {
         if ($user->status == 4) {
             $this->add_phone_number($user->id);
         }
         $cookie = Cookie::forget('rndext');
         $confirmation = App::make('email-confirmation');
         $confirmation->send($user);
         Mail::send('emails.register', array('new_user' => $input['username']), function ($message) {
             $message->from(Config::get('mail.from.address'), Config::get('mail.from.name'))->to(Input::get('email'))->subject(_('New user registration'));
         });
         Event::fire('logger', array(array('account_register', array('id' => $user->id, 'username' => $user->username), 2)));
         //			return Output::push(array(
         //				'path' => 'register',
         //				'messages' => array('success' => _('You have registered successfully')),
         //				));
         return Redirect::to('register')->with('success', _('You have registered successfully'))->withCookie($cookie);
     } else {
         return Output::push(array('path' => 'register', 'messages' => array('fail' => _('Fail to register')), 'input' => TRUE));
     }
 }
Example #12
0
 /**
  * Handle a POST request to reset a user's password.
  *
  * @return Response
  */
 public function postReset()
 {
     $credentials = Input::only('email', 'password', 'token');
     //hack password_confirmation for package
     $credentials['password_confirmation'] = $credentials['password'];
     $rules = array('email' => 'required|email', 'password' => 'required|min:6', 'token' => 'required');
     $v = Validator::make($credentials, $rules);
     if ($v->fails()) {
         return Output::push(array('path' => 'password/reset', 'errors' => $v, 'input' => TRUE));
     }
     //new style
     $validtoken = $this->_isValidToken($credentials['email'], $credentials['token']);
     if ($validtoken) {
         $id = $this->_getUserId($credentials['email']);
         if ($id) {
             $user = user::find($id);
             //$user->username = $input['username'];
             $user->email = $credentials['email'];
             if ($credentials['password']) {
                 $user->password = Hash::make($credentials['password']);
                 Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
             }
             $user->save();
             return Output::push(array('path' => 'login', 'messages' => array('success' => _('Password has been reset'))));
         } else {
             return Output::push(array('path' => 'password/recovery', 'messages' => array('fail' => _('Unable to process password reset'))));
         }
     } else {
         return Output::push(array('path' => 'password/recovery', 'messages' => array('fail' => _('Invalid token'))));
     }
 }
Example #13
0
 /**
  * Отрисовать по шаблону
  * @param String $template
  * @param array $date
  * @return String
  */
 public function fetch($template, $data = false)
 {
     // найти шаблон, он может быть и у любого потомка этого класса, они же и друг от друга наследуют
     $dir = $this->dir;
     $class = get_class($this);
     while (!file_exists($dir . '/' . $template) && !file_exists($template)) {
         $class = get_parent_class($class);
         if ($class) {
             $ref = new ReflectionClass($class);
             if (!$ref->isAbstract()) {
                 $obj = new $class();
                 $dir = $obj->getDir();
             }
         } else {
             return '';
         }
     }
     // Если переданы данные, сделать обозначения
     if ($data !== false) {
         foreach ($data as $key => $value) {
             Output::assign($key, $value);
         }
     }
     $templatedir = Output::getTemplateCompiler()->getTemplateDir();
     Output::getTemplateCompiler()->setTemplateDir($dir);
     $content = Output::fetch($template);
     Output::getTemplateCompiler()->setTemplateDir($templatedir);
     return $content;
 }
Example #14
0
 public function showrec($rec)
 {
     $out = '';
     Output::assign('linkclass', 'path');
     Output::assign('sllink', "file://" . $rec[path]);
     Output::assign('type', 'Путь к блоку');
     Output::assign('slid', '');
     $out .= $this->fetch('link.tpl');
     Output::assign('type', 'СЛ-');
     Output::assign('sllink', $rec[sl][link]);
     Output::assign('slid', $rec[sl][id]);
     Output::assign('linkclass', 'filelink');
     $out .= $this->fetch('link.tpl');
     Output::assign('type', 'ТЗ-');
     Output::assign('sllink', $rec[tz][link]);
     Output::assign('slid', $rec[tz][id]);
     $out .= $this->fetch('link.tpl');
     $out .= "Письма:&nbsp;" . $rec[letter][link];
     // Добавить информацию о платах в блоке
     foreach ($rec[boards] as $value) {
         $files = $value[filelinks][link];
         $out .= $this->fetch('board.tpl', array('boardname' => $value["board_name"], 'filelinks' => $files));
     }
     Output::assign('dozaplink', $rec[dozaplink]);
     Output::assign('filelinks', $out);
     $out = $this->fetch('dozap.tpl');
     $out .= "<script>\$('form[name=dozap]').submit(function(){\n        \$().lego.load('lanch_nzap', \$(this).attr('action'),\$(this).serialize());\n        reload_table();\n        return false;\n    });</script>";
     $out .= $this->addComments($rec[id], 'lanch');
     return $out;
 }
Example #15
0
 function save()
 {
     //echoPre($_POST);die;
     if ($_POST) {
         $dt = array('popup_id' => post('popup_id') != '' ? post('popup_id') : '', 'popup_schedule_start' => post('popup_schedule_start') != '' ? trim(post('popup_schedule_start')) : '', 'popup_schedule_end' => post('popup_schedule_end') != '' ? trim(post('popup_schedule_end')) : '', 'popup_wording' => post('popup_wording') != '' ? strip_tags(post('popup_wording')) : '', 'popup_status' => post('popup_status') != '' ? trim(post('popup_status')) : '', 'popup_url' => post('popup_url') != '' ? trim(post('popup_url')) : '');
         $modeUpdate = false;
         if ($dt['popup_id'] == '') {
             //insert quote
             unset($dt['popup_id']);
             $popup_id = $this->popup_model->insert_data($dt);
         } else {
             //update quote
             $modeUpdate = true;
             $popup_id = $this->popup_model->update_data($dt, $dt['popup_id']);
             $popup_id = $dt['popup_id'];
             $server_cluster = $this->config['server_cluster'];
             foreach ($server_cluster as $serv) {
                 $json = file_get_contents($serv . 'update-json/popup');
                 //echo $serv . 'update-json/popup';
                 //echoPre($json);
             }
         }
         $dt['popup_url'] = $dt['popup_url'] != '' ? $dt['popup_url'] : url_title($popup_id . ' ' . $dt['popup_wording']);
         $this->_prosesImageQuote($dt, $popup_id);
         Output::App()->redirect($this->config['base_url'] . $this->ctrler . '/&s=success');
     } else {
         Output::App()->redirect($this->config['base_url'] . $this->ctrler . '/&s=failed');
         exit;
     }
 }
 /**
  * Print message through output object
  *
  * @param string $message
  * @param boolean $is_error
  * @return null
  */
 function printMessage($message, $is_error = false)
 {
     if ($this->output instanceof Output) {
         $this->output->printMessage($message, $is_error);
     }
     // if
 }
Example #17
0
 /**
  * Execute the given command
  *
  * @param string $command Command to execute
  * @param array  $args    Arguments for command
  *
  * @return mixed $return Command output
  */
 public function run($command, $args = null)
 {
     Output::msg('Executing command: "' . $command . '"');
     // filter the command
     $command = escapeshellcmd($command);
     $descSpec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
     $pipes = null;
     $return = null;
     $process = proc_open($command, $descSpec, $pipes);
     if (is_resource($process)) {
         $return = stream_get_contents($pipes[1]);
         if (empty($return)) {
             // probably some sort of error
             if (is_resource($pipes[2])) {
                 $err = trim(stream_get_contents($pipes[2]));
                 fclose($pipes[2]);
                 throw new \Exception($err);
             }
         }
         fclose($pipes[1]);
         $returnCode = proc_close($process);
         Output::msg("Execution result:\n" . $return);
     }
     return $return;
 }
Example #18
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::only('email', 'username', 'password');
     $rules = array('email' => 'required|email|unique:users,email,' . Auth::user()->id . ',id,deleted_at,NULL,status,' . Auth::user()->status . '');
     if ($input['password']) {
         $rules['password'] = '******';
     }
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         return Output::push(array('path' => 'user', 'errors' => $v, 'input' => TRUE));
     }
     if ($input['password'] && $id && Auth::user()->id == $id) {
         $user = user::find($id);
         //$user->username = $input['username'];
         $user->email = $input['email'];
         if ($input['password']) {
             $user->password = Hash::make($input['password']);
             Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
         }
         $user->save();
         return Output::push(array('path' => 'user', 'errors' => 'Change Password Successfully', 'messages' => array('success', _('User data has been saved')), 'input' => TRUE));
     } else {
         return Output::push(array('path' => 'user', 'errors' => 'Unable to update user', 'messages' => array('fail', _('Unable to update user')), 'input' => TRUE));
     }
 }
Example #19
0
 public static function format($format = 'html', $charset = NULL)
 {
     global $_G;
     self::$charset = $charset = $charset ? strtolower($charset) : $_G['product']['charset'];
     self::$format = $format;
     //关闭缓冲
     //ob_end_clean();
     switch ($format) {
         case 'xml':
             header('Content-Type: text/xml; charset=' . $charset);
             break;
         case 'html':
             header('Content-type: text/html; charset=' . $charset);
             break;
         case 'json':
             header('Content-type: text/javascript; charset=' . $charset);
             break;
         case 'csv':
             header("Cache-Control: public");
             header("Content-type:application/msexcel; charset=" . $charset);
             header("Accept-Ranges: bytes");
             break;
         case 'attachment':
             header("Cache-Control: public");
             header("Content-type:application/octet-stream; charset=" . $charset);
             header("Accept-Ranges: bytes");
             break;
         default:
         case 'text':
             header('Content-Type: text/plain; charset=' . $charset);
             break;
     }
 }
Example #20
0
 /**
  * check for all extensions that are needed, initialize needed vars and read phpsysinfo.ini
  */
 public function __construct($indexname = "dynamic")
 {
     $this->_indexname = $indexname;
     parent::__construct();
     $this->_getTemplateList();
     $this->_getLanguageList();
 }
 /**
  * redirect request to a host by hashing the given url
  * @param $url
  * @param $numberOfHost
  */
 public static function route($url, $numberOfHost)
 {
     $hashNode = static::strHash($url, $numberOfHost);
     $redirectUrl = "http://tumblr-images-{$hashNode}.appspot.com/main.php?url={$url}";
     $redirectUrl = static::encodeCjkChars($redirectUrl);
     Output::redirect($redirectUrl);
 }
Example #22
0
 public function action_register()
 {
     if (\Auth::check()) {
         \Session::set_flash('error', 'FLASH: Can\'t register while logged in, log out first.');
         \Output::redirect('myauth');
     }
     // The same fields as the example above
     $val = \Validation::factory('myauth2');
     $val->add_field('username', 'Your username', 'required|min_length[3]|max_length[20]');
     //        $val->add_field('username', 'Your username', 'required|min_length[3]|max_length[20]|unique[simpleauth.username]');
     $val->add_field('password', 'Your password', 'required|min_length[3]|max_length[20]');
     $val->add_field('email', 'Email', 'required|valid_email');
     // run validation on just post
     if ($val->run()) {
         if (\Auth::instance()->create_user($val->validated('username'), $val->validated('password'), $val->validated('email'), '100')) {
             \Session::set_flash('notice', 'FLASH: User created.');
             \Output::redirect('myauth');
         } else {
             throw new Exception('Smth went wrong while registering');
         }
     } else {
         // validation failed
         if ($_POST) {
             $data['username'] = $val->validated('username');
             $data['login_error'] = 'All fields are required.';
         } else {
             $data['login_error'] = false;
         }
     }
     $this->template->title = 'Myauth &raquo Register';
     $this->template->login_error = @$data['login_error'];
     $this->template->content = \View::factory('register');
 }
Example #23
0
 public function __call($name, $arguments)
 {
     try {
         $replaced = 0;
         $act = str_replace('action_', '', $name, $replaced);
         if ($replaced == 0) {
             throw new Exception("Нет такого метода {$name}");
         }
         $act = $this->getName() . "_" . $act;
         if (class_exists($act)) {
             $this->table = new $act();
         } else {
             $this->table = new sqltable($act);
         }
         if ($this->table == null) {
             throw new Exception("Не возможно создать такую таблицу {$act}");
         }
     } catch (Exception $e) {
         return $this->_404("[class=" . get_class($this) . "] : " . $e->getMessage());
     }
     if ($arguments[nooutput]) {
         return;
     }
     if ($this->table->run()) {
         if (Ajax::isAjaxRequest()) {
             return $this->table->getOutput();
         }
         $this->setOutputAssigns();
         Output::assign('menu', $this->getIndexMenu());
         Output::setContent($this->table->getOutput());
         return $this->fetch("body_base.tpl");
     }
 }
 protected function applyChanges($version, $changes)
 {
     foreach ($changes as $file) {
         $this->output->notice('Applying changeset: ' . $this->versionPrefix . $version . '/' . $file);
         $this->processor->applyFile($this->changesetPath . '/' . $this->versionPrefix . $version . '/' . $file);
         $this->processor->metaChange('INSERT INTO _metaChange (name) VALUES (?)', $file);
     }
 }
Example #25
0
 public function action_404()
 {
     $messages = array('Aw, crap!', 'Bloody Hell!', 'Uh Oh!', 'Nope, not here.', 'Huh?');
     $data['title'] = $messages[array_rand($messages)];
     // Set a HTTP 404 output header
     Output::$status = 404;
     $this->render('welcome/404', $data);
 }
Example #26
0
function ajaxOutput()
{
    global $code, $msg, $data, $respType, $newCrumb, $callback;
    $code = intval($code);
    $msg = (string) $msg;
    Output::out($respType, $code, $msg, $data, $callback, $newCrumb);
    return true;
}
Example #27
0
 function enable()
 {
     $id = $this->uri->get('id');
     if ($id != '') {
         $ret = $this->user_model->updateRecord(array('user_canlogin' => '1'), array('user_id' => $id));
     }
     Output::redirect($this->config['base_url'] . $this->ctrler . '/');
 }
Example #28
0
function json($data, $type = 'eval')
{
    $type = strtolower($type);
    $allow = array('eval', 'alert', 'right', 'notice', 'sucsses');
    if (false == in_array($type, $allow)) {
        return false;
    }
    Output::Json(array('data' => $data, 'type' => $type));
}
Example #29
0
 public function load($db)
 {
     foreach ($this->buildQueries() as $query) {
         Output::verbose($query);
         if (!$db->query($query)) {
             Output::verbose("Fail\n{$query}\n{$db->error}");
         }
     }
 }
Example #30
0
function json($data, $type = 'eval')
{
    $type = strtolower($type);
    $allow = array('eval', 'alert', 'updater', 'dialog', 'mix', 'refresh');
    if (false == in_array($type, $allow)) {
        return false;
    }
    Output::Json(array('data' => $data, 'type' => $type));
}