Ejemplo n.º 1
0
function Logout()
{
    unset($_SESSION['user']);
    session_unset();
    session_destroy();
    Header("Location:Home.php", TRUE);
}
Ejemplo n.º 2
0
 public function getfiles()
 {
     //检查文件是否存在
     if (file_exists($this->_filepath)) {
         //打开文件
         $file = fopen($this->_filepath, "r");
         //返回的文件类型
         Header("Content-type: application/octet-stream");
         //按照字节大小返回
         Header("Accept-Ranges: bytes");
         //返回文件的大小
         Header("Accept-Length: " . filesize($this->_filepath));
         //这里对客户端的弹出对话框,对应的文件名
         Header("Content-Disposition: attachment; filename=" . $this->_filename);
         //修改之前,一次性将数据传输给客户端
         echo fread($file, filesize($this->_filepath));
         //修改之后,一次只传输1024个字节的数据给客户端
         //向客户端回送数据
         $buffer = 1024;
         //
         //判断文件是否读完
         while (!feof($file)) {
             //将文件读入内存
             $file_data = fread($file, $buffer);
             //每次向客户端回送1024个字节的数据
             echo $file_data;
         }
         fclose($file);
     } else {
         echo "<script>alert('对不起,您要下载的文件不存在');</script>";
     }
 }
Ejemplo n.º 3
0
function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $_SESSION["my_checkcode"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(5, 10);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(1, 6);
        imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += $w / 5;
    }
    imagepng($im);
    imagedestroy($im);
}
Ejemplo n.º 4
0
function getClient()
{
    $config = (include __DIR__ . '/ini.php');
    $client = new Google_Client();
    $client->setApplicationName("Webkameleon");
    $client->setClientId($config['oauth2_client_id']);
    $client->setClientSecret($config['oauth2_client_secret']);
    $client->setRedirectUri($config['oauth2_redirect_uri']);
    $client->setScopes($config['oauth2_scopes']);
    $client->setState('offline');
    $client->setAccessType('offline');
    $client->setApprovalPrompt('force');
    if (isset($_GET['code'])) {
        $client->authenticate($_GET['code']);
        die($client->getAccessToken());
    } elseif (!isset($config['token'])) {
        Header('Location: ' . $client->createAuthUrl());
    } else {
        $client->setAccessToken($config['token']);
        if ($client->isAccessTokenExpired()) {
            $token = json_decode($config['token'], true);
            $client->refreshToken($token['refresh_token']);
        }
    }
    return $client;
}
Ejemplo n.º 5
0
 public function handler()
 {
     global $tmpl, $page, $ms;
     if (isset($this->rights)) {
         /* If authentication is enabled, check permissions */
         if ($ms->getOption("authentication") == "Y" && !$ms->checkPermissions($this->rights)) {
             $ms->throwError("<img src=\"" . ICON_CHAINS . "\" alt=\"chain icon\" />&nbsp;" . _("Manage Chains"), _("You do not have enough permissions to access this module!"));
             return 0;
         }
     }
     switch ($page->action) {
         case 'overview':
         case 'chains':
         case 'pipes':
         case 'bandwidth':
         case 'options':
         case 'about':
         case 'tasklist':
         case 'update-iana':
         case 'list':
             $content = $this->showList();
             break;
         case 'edit':
         case 'new':
             $content = $this->showEdit();
             break;
     }
     if ($ms->get_header('Location')) {
         Header('Location: ' . $ms->get_header('Location'));
         return false;
     }
     if (isset($content)) {
         $tmpl->assign('content', $content);
     }
 }
Ejemplo n.º 6
0
function action_snippet_exporte(){
	global $auteur_session;
	$arg = _request('arg');
	$args = explode(":",$arg);
	$hash = _request('hash');
	$id_auteur = $auteur_session['id_auteur'];
	$redirect = _request('redirect');
	if ($redirect==NULL) $redirect="";
	include_spip("inc/securiser_action");
	if (verifier_action_auteur("snippet_exporte-$arg",$hash,$id_auteur)==TRUE) {
		$table = $args[0];
		$id = $args[1];
		
		$f = snippets_fond_exporter($table, false);
			
		if ($f) {
			include_spip('public/assembler');
			$out = recuperer_fond($f,array('id'=>intval($id)));
			//$out = preg_replace(",\n\n[\s]*(?=\n),","",$out);
			
			$filename=str_replace(":","_",$arg);
			if (preg_match(",<titre>(.*)</titre>,Uims",$out,$regs))
				$filename = preg_replace(',[^-_\w]+,', '_', trim(translitteration(textebrut(typo($regs[1])))));
			$extension = "xml";
			
			Header("Content-Type: text/xml; charset=".$GLOBALS['meta']['charset']);
			Header("Content-Disposition: attachment; filename=$filename.$extension");
			Header("Content-Length: ".strlen($out));
			echo $out;
			exit();
		}
	}	
	redirige_par_entete(str_replace("&amp;","&",urldecode($redirect)));
}
Ejemplo n.º 7
0
 public function registerWithFacebook()
 {
     if ($this->registration->registerWithFacebook()) {
         Header('Location:' . URL);
     } else {
     }
 }
Ejemplo n.º 8
0
 function render()
 {
     $tplHelper = $this->getTplHelper(array());
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_statics, '');
     # vraag de content op
     $mergedInfo = $this->mergeFiles($tplHelper->getStaticFiles($this->_params['type']));
     # Er is een bug met mod_deflate en mod_fastcgi welke ervoor zorgt dat de content-length
     # header niet juist geupdate wordt. Als we dus mod_fastcgi detecteren, dan sturen we
     # content-length header niet mee
     if (isset($_SERVER['REDIRECT_HANDLER']) && $_SERVER['REDIRECT_HANDLER'] != 'php-fastcgi') {
         Header("Content-Length: " . strlen($mergedInfo['body']));
     }
     # if
     # en stuur de versie specifieke content
     switch ($this->_params['type']) {
         case 'css':
             Header('Content-Type: text/css');
             Header('Vary: Accept-Encoding');
             // sta toe dat proxy servers dit cachen
             break;
         case 'js':
             Header('Content-Type: application/javascript; charset=utf-8');
             break;
         case 'ico':
             Header('Content-Type: image/x-icon');
             break;
     }
     # switch
     # stuur de expiration headers
     $this->sendExpireHeaders(false);
     # stuur de last-modified header
     Header("Last-Modified: " . gmdate("D, d M Y H:i:s", $tplHelper->getStaticModTime($this->_params['type'])) . " GMT");
     echo $mergedInfo['body'];
 }
Ejemplo n.º 9
0
 function render()
 {
     $spotnntp_hdr = new SpotNntp($this->_settings->get('nntp_hdr'));
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotimage, '');
     # Haal de volledige spotinhoud op
     $fullSpot = $this->_tplHelper->getFullSpot($this->_messageid, true);
     # sluit de connectie voor de header, en open een nieuwe connectie voor de nzb
     $spotnntp_hdr->quit();
     $spotnntp_img = new SpotNntp($this->_settings->get('nntp_nzb'));
     # Images mogen gecached worden op de client
     $this->sendExpireHeaders(false);
     #
     # is het een array met een segment nummer naar de image, of is het
     # een string met de URL naar de image?
     #
     if (is_array($fullSpot['image'])) {
         Header("Content-Type: image/jpeg");
         echo $spotnntp_img->getImage($fullSpot['image']['segment']);
     } else {
         $x = file_get_contents($fullSpot['image']);
         foreach ($http_response_header as $hdr) {
             if (substr($hdr, 0, strlen('Content-Type: ')) == 'Content-Type: ') {
                 header($hdr);
             }
             # if
         }
         # foreach
         echo $x;
     }
     # else
 }
	private function executarLogin() {
		$this->system->load->dao('login');

	    $dados = $this->system->login->getLoginDao($this->system->input['usuario'], $this->system->input['senha']);
		if ($dados) {
			$this->system->session->addItem('session_cod_usuario', $dados->id);
			$this->system->session->addItem('session_logged_in', true);
			$this->system->session->addItem('session_nome', $dados->nome);
			$this->system->session->addItem('session_email', $dados->email);
			$this->system->session->addItem('session_senha', $dados->senha);
			$this->system->session->addItem('session_nivel', $dados->nivel);

			switch($dados->nivel) {
				case 1:
					$nivel = 'administrador';
					break;
				case 2:
					$nivel = 'coordenador';
					break;
			}

			$this->permitido = true;
	        $this->system->login->updateEntrada();
	        Header('location: /lms/' . $nivel . '/dashboard/home');
		}
	}
Ejemplo n.º 11
0
 function get_VM($user, $mid, &$errors)
 {
     global $config, $lang_str;
     if (!$this->connect_to_db($errors)) {
         return false;
     }
     $q = "select subject, file from " . $config->data_sql->table_voice_silo . " where mid=" . $mid . " and " . $this->get_indexing_sql_where_phrase_uri($user);
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         log_errors($res, $errors);
         return false;
     }
     if (!$res->numRows()) {
         $errors[] = $lang_str['err_voice_msg_not_found'];
         return false;
     }
     $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
     $res->free();
     @($fp = fopen($config->voice_silo_dir . $row->file, 'r'));
     if (!$fp) {
         $errors[] = $lang_str['err_can_not_open_message'];
         return false;
     }
     Header("Content-Disposition: attachment;filename=" . RawURLEncode(($row->subject ? $row->subject : "received message") . ".wav"));
     Header("Content-type: audio/wav");
     @fpassthru($fp);
     @fclose($fp);
     return true;
 }
Ejemplo n.º 12
0
function getCode($num, $w, $h)
{
    $code = "";
    for ($i = 0; $i < $num; $i++) {
        $code .= rand(0, 9);
    }
    //4位验证码也可以用rand(1000,9999)直接生成
    //将生成的验证码写入session,备验证页面使用
    $_SESSION['yzm'] = $code;
    //setcookie("mimi", md5($code), time()+1200);
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, 255, 0, 63);
    $gray = imagecolorallocate($im, 200, 200, 200);
    $bgcolor = imagecolorallocate($im, 255, 255, 255);
    imagefill($im, 0, 0, $bgcolor);
    //画边框
    //imagerectangle($im, 0, 0, $w-1, $h-1, $black);
    //在画布上随机生成大量黑点,起干扰作用;
    for ($i = 0; $i < 10; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(1, 3);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(2, 6);
        imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += rand(8, 12);
    }
    imagepng($im);
    imagedestroy($im);
}
Ejemplo n.º 13
0
function logon()
{
    Header("WWW-Authenticate: Basic Realm=\"phpOracleAdmin\"");
    Header("HTTP/1.0 401 Unauthorized");
    echo "Access Denied!";
    exit;
}
Ejemplo n.º 14
0
 public function Output($name = 'mescontacts.pdf', $dest = 'I')
 {
     Header('Pragma: public');
     error_reporting(0);
     parent::Output($name, $dest);
     error_reporting($this->report);
 }
Ejemplo n.º 15
0
 function sendContentTypeHeader($type)
 {
     switch ($type) {
         case 'xml':
             Header("Content-Type: text/xml; charset=utf-8");
             break;
         case 'rss':
             Header("Content-Type: application/rss+xml; charset=utf-8");
             break;
         case 'json':
             Header("Content-Type: application/json; charset=utf-8");
             break;
         case 'css':
             Header("Content-Type: text/css; charset=utf-8");
             break;
         case 'js':
             Header("Content-Type: application/javascript; charset=utf-8");
             break;
         case 'ico':
             Header("Content-Type: image/x-icon");
             break;
         default:
             Header("Content-Type: text/html; charset=utf-8");
             break;
     }
     # switch
 }
Ejemplo n.º 16
0
function create_captcha($width = 60, $height = 32)
{
    session_start();
    //生成验证码图片
    Header("Content-type: image/PNG");
    $im = imagecreate($width, $height);
    // width and height of image
    $back = ImageColorAllocate($im, 245, 245, 245);
    // specify background color
    imagefill($im, 0, 0, $back);
    // fill the background color into image
    $vcodes = "";
    srand((double) microtime() * 1000000);
    //生成4位数字
    for ($i = 0; $i < 4; $i++) {
        $font = ImageColorAllocate($im, rand(100, 255), rand(0, 100), rand(100, 255));
        // 生成随机颜色
        $authnum = rand(1, 9);
        $vcodes .= $authnum;
        imagestring($im, 5, 2 + $i * 10, 1, $authnum, $font);
    }
    for ($i = 0; $i < 100; $i++) {
        // interuppting
        $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
        imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
        // 画像素点函数
    }
    ImagePNG($im);
    ImageDestroy($im);
    $_SESSION['captcha'] = $vcodes;
}
Ejemplo n.º 17
0
 function excluir()
 {
     $id = $this->getParam('id');
     $produtosModel = new produtosModel();
     $produtosModel->del($id);
     Header("Location: /produtos");
 }
Ejemplo n.º 18
0
function JPGText($str, $fontname, $fontsize, $backcol, $txtcol)
{
    global $layout;
    Header("Last-Modified: " . gmDate("D, d M Y H:i:s", Time()) . " GMT");
    Header("Expires: " . gmDate("D, d M Y H:i:s", Time() - 3601) . " GMT");
    Header("Pragma: no-cache");
    Header("Cache-control: no-cache");
    Header("Content-Type: image/jpeg");
    $a = ImageTTFBBox($fontsize, 0, $fontname, $str);
    $width = $a[2] + 4;
    $bla = get_maximum_height($fontname, $fontsize);
    $height = $bla[0] + 3;
    $bl = $bla[1];
    $im = ImageCreate($width, $height);
    $bgcol = ImageColorAllocate($im, $backcol['red'], $backcol['green'], $backcol['blue']);
    $fgcol = ImageColorAllocate($im, $txtcol['red'], $txtcol['green'], $txtcol['blue']);
    if (!function_exists(imagegif)) {
        imageTTFText($im, $fontsize, 0, 2, $bl + $fontsize / 6 + 2, $fgcol, $fontname, $str);
        imagejpeg($im, "", 80);
    } else {
        ImageColorTransparent($im, $bgcol);
        imageTTFText($im, $fontsize, 0, 2, $bl + $fontsize / 6 + 2, $fgcol, $fontname, $str);
        imagegif($im);
    }
    ImageDestroy($im);
}
Ejemplo n.º 19
0
function rand_create()
{
    //通知浏览器将要输出PNG图片
    Header("Content-type: image/PNG");
    //准备好随机数发生器种子
    srand((double) microtime() * 1000000);
    //准备图片的相关参数
    $im = imagecreate(62, 20);
    $black = ImageColorAllocate($im, 0, 0, 0);
    //RGB黑色标识符
    $white = ImageColorAllocate($im, 255, 255, 255);
    //RGB白色标识符
    $gray = ImageColorAllocate($im, 200, 200, 200);
    //RGB灰色标识符
    //开始作图
    imagefill($im, 0, 0, $gray);
    while (($randval = rand() % 100000) < 10000) {
    }
    $_SESSION["login_check_num"] = $randval;
    //将四位整数验证码绘入图片
    imagestring($im, 5, 10, 3, $randval, $black);
    //加入干扰象素
    for ($i = 0; $i < 200; $i++) {
        $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
        imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
    }
    //输出验证图片
    ImagePNG($im);
    //销毁图像标识符
    ImageDestroy($im);
}
 public function edit($id)
 {
     if (!$this->isLogged()) {
         Header('Location: ' . $this->directories . '/users/login');
     }
     // TODO FIX LOCIAL STATEMENT
     if ($_SESSION['role'] != 'admin') {
         if ($_SESSION['role'] != 'editor') {
             Header('Location: ' . $this->directories . '/home/index');
         }
     }
     $model = new Category();
     $model->pageTitle = 'Edit Category';
     if (isset($_POST['title'])) {
         try {
             $title = $_POST['title'];
             $model->edit($id, $title);
             $model->success = 'New name of category - ' . $title . '.';
             header("refresh:1;" . $this->directories . '/categories/show');
         } catch (\Exception $e) {
             $model->error = $e->getMessage();
             return new View($model);
         }
     }
     return new View($model);
 }
Ejemplo n.º 21
0
 /**
  * Load the controller and execute requested action.
  *
  * @access public
  * @return void
  */
 public function loader()
 {
     // check the route
     $this->getController();
     // if controller not found, redirect to front page
     if (is_readable($this->file) == false) {
         Header("Location: /");
     }
     // include the controller
     include $this->file;
     // create new controller class instance
     $class = $this->controller;
     $controller = new $class();
     // set controller and action names in the template
     $controller->template->controller = strtolower(preg_replace("/Controller/", "", $this->controller));
     $controller->template->action = strtolower($this->action);
     // set the page title in the template (can be overridden by controllers if required)
     $controller->template->title = APP_TITLE . " - " . ucfirst(preg_replace("/Controller/", "", $this->controller)) . " - " . ucfirst($this->action);
     // check if the action is callable, if it's not then default to "index"
     // action which must be present in all controllers
     if (is_callable(array($controller, $this->action)) == false) {
         $action = "index";
     } else {
         $action = $this->action;
     }
     // run the action
     $controller->{$action}();
 }
Ejemplo n.º 22
0
 public function index($user = '')
 {
     //echo $_GET['user'];
     if (isset($_SESSION["user_logged_in"]) && $_SESSION["user_logged_in"] == true && isset($_SESSION["username"])) {
         if ($this->user->checkUserExistAndGetType($user) != '') {
             if ($this->user->checkUserExistAndGetType($user)->user_account_type == 1) {
                 $this->user_name = $user;
                 $this->view('user_profile/normal_user_profile');
             } else {
                 if ($this->user->checkUserExistAndGetType($user)->user_account_type == 3) {
                     $this->user_name = $user;
                     $this->view('user_profile/normal_user_profile');
                 } else {
                     if ($this->user->checkUserExistAndGetType($user)->user_account_type == 2) {
                         $this->user_name = $user;
                         $this->view('user_profile/cooperate_user_updated');
                     }
                 }
             }
         } else {
             $this->view('_template/error');
         }
     } else {
         Header('Location:/Ambula/login/');
     }
 }
Ejemplo n.º 23
0
 public function request($Amount, $Description, $Email, $Mobile, $CallBack, $base_url)
 {
     //        require_once($_SERVER['DOCUMENT_ROOT'] . '/assets/lib/nusoap.php');
     $soup = $base_url . '/assets/lib/nusoap.php';
     //        echo $soup;
     include "{$soup}";
     switch ($CallBack) {
         case 'advertVijeh':
             $CallbackURL = $this->domain . '/form/verify';
             // Required
             break;
         case 'kharid_file':
             $CallbackURL = $this->domain . '/form/verify';
             // Required
             break;
     }
     // URL also Can be https://ir.zarinpal.com/pg/services/WebGate/wsdl
     $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl');
     $client->soap_defencoding = 'UTF-8';
     $result = $client->call('PaymentRequest', array(array('MerchantID' => $this->MerchantID, 'Amount' => $Amount, 'Description' => $Description, 'Email' => $Email, 'Mobile' => $Mobile, 'CallbackURL' => $CallbackURL)));
     //Redirect to URL You can do it also by creating a form
     if ($result['Status'] == 100) {
         Header('Location: https://www.zarinpal.com/pg/StartPay/' . $result['Authority']);
     } else {
         echo 'ERR: ' . $result['Status'];
     }
 }
Ejemplo n.º 24
0
 function getAuthImage($text)
 {
     $this->setpin($text);
     $im_x = 160;
     $im_y = 40;
     $im = imagecreatetruecolor($im_x, $im_y);
     $text_c = ImageColorAllocate($im, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
     $tmpC0 = mt_rand(100, 255);
     $tmpC1 = mt_rand(100, 255);
     $tmpC2 = mt_rand(100, 255);
     $buttum_c = ImageColorAllocate($im, $tmpC0, $tmpC1, $tmpC2);
     imagefill($im, 16, 13, $buttum_c);
     $font = PATH_SYS_PUBLIC . 'font-awesome/fonts/verdana.ttf';
     for ($i = 0; $i < strlen($text); $i++) {
         $tmp = substr($text, $i, 1);
         $array = array(-1, 1);
         $p = array_rand($array);
         $an = $array[$p] * mt_rand(1, 10);
         //角度
         $size = 28;
         imagettftext($im, $size, $an, 15 + $i * $size, 35, $text_c, $font, $tmp);
     }
     $distortion_im = imagecreatetruecolor($im_x, $im_y);
     imagefill($distortion_im, 16, 13, $buttum_c);
     for ($i = 0; $i < $im_x; $i++) {
         for ($j = 0; $j < $im_y; $j++) {
             $rgb = imagecolorat($im, $i, $j);
             if ((int) ($i + 20 + sin($j / $im_y * 2 * M_PI) * 10) <= imagesx($distortion_im) && (int) ($i + 20 + sin($j / $im_y * 2 * M_PI) * 10) >= 0) {
                 imagesetpixel($distortion_im, (int) ($i + 10 + sin($j / $im_y * 2 * M_PI - M_PI * 0.1) * 4), $j, $rgb);
             }
         }
     }
     //加入干扰象素;
     $count = 160;
     //干扰像素的数量
     for ($i = 0; $i < $count; $i++) {
         $randcolor = ImageColorallocate($distortion_im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($distortion_im, mt_rand() % $im_x, mt_rand() % $im_y, $randcolor);
     }
     $rand = mt_rand(5, 30);
     $rand1 = mt_rand(15, 25);
     $rand2 = mt_rand(5, 10);
     for ($yy = $rand; $yy <= +$rand + 2; $yy++) {
         for ($px = -80; $px <= 80; $px = $px + 0.1) {
             $x = $px / $rand1;
             if ($x != 0) {
                 $y = sin($x);
             }
             $py = $y * $rand2;
             imagesetpixel($distortion_im, $px + 80, $py + $yy, $text_c);
         }
     }
     //设置文件头;
     Header("Content-type: image/JPEG");
     //以PNG格式将图像输出到浏览器或文件;
     ImagePNG($distortion_im);
     //销毁一图像,释放与image关联的内存;
     ImageDestroy($distortion_im);
     ImageDestroy($im);
 }
Ejemplo n.º 25
0
 function redirect($filename)
 {
     Header("Content-Type: text/xml; charset=" . $this->encoding . "; filename=" . basename($filename));
     Header("Content-Disposition: inline; filename=" . basename($filename));
     readfile($filename, "r");
     die;
 }
Ejemplo n.º 26
0
 function render()
 {
     $spotnntp_hdr = new SpotNntp($this->_settings['nntp_hdr']);
     # Haal de volledige spotinhoud op
     $spotsOverview = new SpotsOverview($this->_db, $this->_settings);
     $fullSpot = $spotsOverview->getFullSpot($this->_messageid, $spotnntp_hdr);
     # sluit de connectie voor de header, en open een nieuwe connectie voor de nzb
     $spotnntp_hdr->quit();
     $spotnntp_img = new SpotNntp($this->_settings['nntp_nzb']);
     #
     # is het een array met een segment nummer naar de image, of is het
     # een string met de URL naar de image?
     #
     if (is_array($fullSpot['image'])) {
         Header("Content-Type: image/jpeg");
         echo $spotnntp_img->getImage($fullSpot['image']['segment']);
     } else {
         $x = file_get_contents($fullSpot['image']);
         foreach ($http_response_header as $hdr) {
             if (substr($hdr, 0, strlen('Content-Type: ')) == 'Content-Type: ') {
                 header($hdr);
             }
             # if
         }
         # foreach
         echo $x;
     }
     # else
 }
 protected function downFile($path, $file_name)
 {
     header("Content-type:text/html;charset=utf-8");
     // echo $path,$file_name;
     //中文兼容
     $file_name = iconv("utf-8", "gb2312", $file_name);
     //获取网站根目录,这里可以换成你的下载目录
     $file_sub_path = $path;
     $file_path = $file_sub_path . $file_name;
     //判断文件是否存在
     if (!file_exists($file_path)) {
         echo '文件不存在';
         return;
     }
     $fp = fopen($file_path, "r");
     $file_size = filesize($file_path);
     //下载文件所需的header申明
     Header("Content-type: application/octet-stream");
     Header("Accept-Ranges: bytes");
     Header("Accept-Length:" . $file_size);
     Header("Content-Disposition: attachment; filename=" . $file_name);
     $buffer = 1024;
     $file_count = 0;
     //返回数据到浏览器
     while (!feof($fp) && $file_count < $file_size) {
         $file_con = fread($fp, $buffer);
         $file_count += $buffer;
         echo $file_con;
     }
     fclose($fp);
 }
 public function init(Application $app, $options = array())
 {
     parent::init($app, $options);
     $app->addTemplatesFolders(__DIR__ . '/views/');
     $app->get('login', 'AnyContent\\CMCK\\Modules\\Backend\\Core\\User\\Controller::login')->bind('login');
     $app->post('login', 'AnyContent\\CMCK\\Modules\\Backend\\Core\\User\\Controller::post')->bind('postLogin');
     $app->get('logout', 'AnyContent\\CMCK\\Modules\\Backend\\Core\\User\\Controller::logout')->bind('logout');
     $app['user'] = $app->share(function ($app) {
         return new UserManager($app, $app['context'], $app['config'], $app['session']);
     });
     // Perform a hard redirect, if no user is logged in
     $app->before(function (Request $request) use($app) {
         $parts = explode('/', trim($request->getPathInfo(), '/'));
         if (isset($parts[0]) && !in_array($parts[0], array('login', 'css', 'js', 'public'))) {
             if (!$app['user']->isLoggedIn()) {
                 Header('Location: ' . $app['url_generator']->generate('login'), 303);
                 die;
             }
         }
     });
     if ($this->app['env'] == 'console') {
         $app->registerAuthenticationAdapter('config', 'AnyContent\\CMCK\\Modules\\Backend\\Core\\User\\ConsoleAuthenticationAdapter');
     } else {
         $app->registerAuthenticationAdapter('config', 'AnyContent\\CMCK\\Modules\\Backend\\Core\\User\\ConfigAuthenticationAdapter');
     }
 }
Ejemplo n.º 29
0
 public function index()
 {
     // Get all active scheduled items
     foreach (ORM::factory('scheduler')->where('scheduler_active', '1')->find_all() as $scheduler) {
         $scheduler_id = $scheduler->id;
         $scheduler_last = $scheduler->scheduler_last;
         // Next run time
         $scheduler_weekday = $scheduler->scheduler_weekday;
         // Day of the week
         $scheduler_day = $scheduler->scheduler_day;
         // Day of the month
         $scheduler_hour = $scheduler->scheduler_hour;
         // Hour
         $scheduler_minute = $scheduler->scheduler_minute;
         // Minute
         // Controller that performs action
         $scheduler_controller = $scheduler->scheduler_controller;
         if ($scheduler_day <= -1) {
             // Ran every day?
             $scheduler_day = "*";
         }
         if ($scheduler_weekday <= -1) {
             // Ran every day?
             $scheduler_weekday = "*";
         }
         if ($scheduler_hour <= -1) {
             // Ran every hour?
             $scheduler_hour = "*";
         }
         if ($scheduler_minute <= -1) {
             // Ran every minute?
             $scheduler_minute = "*";
         }
         $scheduler_cron = $scheduler_minute . " " . $scheduler_hour . " " . $scheduler_day . " * " . $scheduler_weekday;
         //Start new cron parser instance
         $cron = new CronParser($scheduler_cron);
         $lastRan = $cron->getLastRan();
         //Array (0=minute, 1=hour, 2=dayOfMonth, 3=month, 4=week, 5=year)
         $cronRan = mktime($lastRan[1], $lastRan[0], 0, $lastRan[3], $lastRan[2], $lastRan[5]);
         if (!($scheduler_last > $cronRan - 45) || $scheduler_last == 0) {
             // within 45 secs of cronRan time, so Execute control
             $site_url = "http://" . $_SERVER['SERVER_NAME'] . "/";
             $scheduler_status = remote::status($site_url . "scheduler/" . $scheduler_controller);
             // Set last time of last execution
             $schedule_time = time();
             $scheduler->scheduler_last = $schedule_time;
             $scheduler->save();
             // Record Action to Log
             $scheduler_log = new Scheduler_Log_Model();
             $scheduler_log->scheduler_id = $scheduler_id;
             $scheduler_log->scheduler_name = $scheduler->scheduler_name;
             $scheduler_log->scheduler_status = $scheduler_status;
             $scheduler_log->scheduler_date = $schedule_time;
             $scheduler_log->save();
         }
     }
     Header("Content-Type: image/gif");
     // Transparent GIF
     echo base64_decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
 }
Ejemplo n.º 30
0
 public function verify()
 {
     //生成验证码图片
     Header("Content-type: image/PNG");
     $im = imagecreate(44, 18);
     // 画一张指定宽高的图片
     $back = ImageColorAllocate($im, 245, 245, 245);
     // 定义背景颜色
     imagefill($im, 0, 0, $back);
     //把背景颜色填充到刚刚画出来的图片中
     $vcodes = "";
     srand((double) microtime() * 1000000);
     //生成4位数字
     for ($i = 0; $i < 4; $i++) {
         $font = ImageColorAllocate($im, rand(100, 255), rand(0, 100), rand(100, 255));
         // 生成随机颜色
         $authnum = rand(1, 9);
         $vcodes .= $authnum;
         imagestring($im, 5, 2 + $i * 10, 1, $authnum, $font);
     }
     $_SESSION['v_code'] = $vcodes;
     for ($i = 0; $i < 200; $i++) {
         $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
         imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
         // 画像素点函数
     }
     ImagePNG($im);
     ImageDestroy($im);
 }