note 109918 added to varnish.example.admin

From: Date: Mon, 03 Sep 2012 08:57:49 +0000
Subject: note 109918 added to varnish.example.admin
Groups: php.notes 
Request: Send a blank email to php-notes+get-190442@lists.php.net to get a copy of this message
This code worked for me with couple of changes after installing PECL. Here is the updated code. <?php $args = array( VARNISH_CONFIG_HOST => "127.0.0.1", VARNISH_CONFIG_PORT => 6082, VARNISH_CONFIG_SECRET => "5174826b-8595-4958-aa7a-0609632ad7ca", VARNISH_CONFIG_TIMEOUT => 300, ); $va = new VarnishAdmin($args); try { if(!$va->connect()) { throw new VarnishException("Connection failed\n"); } } catch (VarnishException $e) { echo $e->getMessage(); exit(3); } try { if(!$va->auth()) { throw new VarnishException("Auth failed\n"); } } catch (VarnishException $e) { echo $e->getMessage(); exit(3); } try { $status = $va->ban('req.url ~ "^/."'); if (VARNISH_STATUS_OK != $status) { throw new VarnishException("Ban method returned $status status\n"); } } catch (VarnishException $e) { echo $e->getMessage(); exit(3); } exit(0); ?> Hope this helps. ---- Server IP: 69.147.83.197 Probable Submitter: 202.143.126.157 ---- Manual Page -- http://www.php.net/manual/en/varnish.example.admin.php Edit -- https://master.php.net/note/edit/109918 Del: integrated -- https://master.php.net/note/delete/109918/integrated Del: useless -- https://master.php.net/note/delete/109918/useless Del: bad code -- https://master.php.net/note/delete/109918/bad+code Del: spam -- https://master.php.net/note/delete/109918/spam Del: non-english -- https://master.php.net/note/delete/109918/non-english Del: in docs -- https://master.php.net/note/delete/109918/in+docs Del: other reasons-- https://master.php.net/note/delete/109918 Reject -- https://master.php.net/note/reject/109918 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190442) next »