]> git.quilime.com - plog.git/commitdiff
comments
authorGabriel Dunne <gdunne@quilime.com>
Thu, 10 Nov 2011 12:21:47 +0000 (17:51 +0530)
committerGabriel Dunne <gdunne@quilime.com>
Thu, 10 Nov 2011 12:21:47 +0000 (17:51 +0530)
30 files changed:
comments/categori1/cat_2/hello_comments/1320927226.json [new file with mode: 0644]
comments/categori1/cat_2/hello_comments/1320927283.json [new file with mode: 0644]
comments/categori1/cat_2/hello_comments/1320927295.json [new file with mode: 0644]
content/.DS_Store [new file with mode: 0644]
content/2011/09/arrive [deleted file]
content/2011/09/beg [deleted file]
content/2011/09/habitat [deleted file]
content/2011/09/sriyantra [deleted file]
content/2011/10/alphabet [deleted file]
content/2011/10/dreams [deleted file]
content/2011/10/dushera [deleted file]
content/2011/10/islands [deleted file]
content/2011/10/overlords [deleted file]
content/2011/10/smog [deleted file]
content/2011/10/water_is_life [deleted file]
content/categori1/.DS_Store [new file with mode: 0644]
content/categori1/cat_2/hello_comments [new file with mode: 0644]
content/config [deleted file]
content/hello_world [new file with mode: 0644]
css/comments.css [new file with mode: 0644]
css/style.css
lib/comments.php [new file with mode: 0644]
lib/data.php
lib/init.php
lib/recaptchalib.php [new file with mode: 0644]
pages/about
pages/links [deleted file]
templates/comments.html.tpl [new file with mode: 0644]
templates/entry.html.tpl
templates/head-inc.html.tpl

diff --git a/comments/categori1/cat_2/hello_comments/1320927226.json b/comments/categori1/cat_2/hello_comments/1320927226.json
new file mode 100644 (file)
index 0000000..4278222
--- /dev/null
@@ -0,0 +1 @@
+{"name":"","www":"","timestamp":"1320927226","comment":"this is a test comment"}
\ No newline at end of file
diff --git a/comments/categori1/cat_2/hello_comments/1320927283.json b/comments/categori1/cat_2/hello_comments/1320927283.json
new file mode 100644 (file)
index 0000000..ec6d30b
--- /dev/null
@@ -0,0 +1 @@
+{"name":"test","www":null,"timestamp":"1320927283","comment":"what a test"}
\ No newline at end of file
diff --git a/comments/categori1/cat_2/hello_comments/1320927295.json b/comments/categori1/cat_2/hello_comments/1320927295.json
new file mode 100644 (file)
index 0000000..5e4c9f2
--- /dev/null
@@ -0,0 +1 @@
+{"name":"anonymous","www":null,"timestamp":"1320927295","comment":"test test test test test "}
\ No newline at end of file
diff --git a/content/.DS_Store b/content/.DS_Store
new file mode 100644 (file)
index 0000000..16b6615
Binary files /dev/null and b/content/.DS_Store differ
diff --git a/content/2011/09/arrive b/content/2011/09/arrive
deleted file mode 100644 (file)
index 7b269eb..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-date = Sept 22 2011, 22:50
-title = arrival
---
-                                        Bkng                          Meals/ Seat/
-       Day Date       Flight     Status Class       City        Time  Other  Cabin
-       --- ----- --------------- ------ ----- ---------------- ------ ------ -------
-       Thu 22SEP KLM ROYAL         OK     T   LV SAN FRANCISCO 200P     M     **
-                 DUTCH AIRLINES 606           AR AMSTERDAM     915A#         
-
-       Fri 23SEP KLM ROYAL         OK     T   LV AMSTERDAM     1120A    M     **
-                 DUTCH AIRLINES 871           AR DELHI         1050P         
diff --git a/content/2011/09/beg b/content/2011/09/beg
deleted file mode 100644 (file)
index 5056e40..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-title = beg
-date = Oct 16 2011, 15:34:03; IST 
---
-
-
-
-<img src="photos/P1010976.jpg">
-
-Tapping on the windows, the begger kids have perfected their methods. They move their mouths into a sad frown, they use their eyes, they tap on the windows. 
\ No newline at end of file
diff --git a/content/2011/09/habitat b/content/2011/09/habitat
deleted file mode 100644 (file)
index ff3e862..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-title = habitat
-date = 2011-9-27
---
-
-
-<img src="photos/IMG_1003.jpg" />
-
-view from vishal's room onto the up and coming Guargon area, outside Delhi
diff --git a/content/2011/09/sriyantra b/content/2011/09/sriyantra
deleted file mode 100644 (file)
index e2fc30a..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-date = 2011-09-28
-title = sri yantra
---
-
-<!--<img src="media/sriyantra/sri_light.png">  -->
-<img src="media/sriyantra/sri_bindu.png">  
-<!--<img src="media/sriyantra/sri_dark.png">  -->
-Shri Yantra
-
-<img src="media/sriyantra/kali-yantra.jpg" />    
-Kali &rarr; goddess of eternal energy. "She who destroys all". The goddess of time and change. The ultimate reality.
-
-
-> The Sri Chakra or Shri Yantra of Tripura Sundari is a yantra or mandala formed by nine interlocking triangles surrounding the bindu. Four of these triangles are orientated upright representing Shiva or the Masculine. Five of these triangles are inverted triangles represent Shakti or the Feminine. Because it is composed of nine triangles, it is also known as the Navayoni Chakra.[1]
-
-<img src="media/sriyantra/sri_guides.png" />  
-<em>sri yantra guides</em>  
-
-> Together the nine triangles are interlaced in such a way as to form 43 smaller triangles in a web symbolic of the entire cosmos or a womb symbolic of creation. Together they express Advaita or non-duality. This is surrounded by a lotus of eight petals, a lotus of sixteen petals, and an earth square resembling a temple with four doors.[1]
-
-> The Shri Chakra is also known as the nava chakra because it can also be seen as having nine levels. Each level corresponds to a mudra, a yogini, and a specific form of the deity Tripura Sundari along with her mantra. These levels starting from the outside or bottom layer are:[1]
-
-1. Trailokya Mohana or Bhupara, a square of three lines with four portals
-2. Sarvasa Paripuraka, a sixteen-petal lotus
-3. Sarva Sankshobahana, an eight-petal lotus
-4. Sarva Saubhagyadayaka, composed of fourteen small triangles
-5. Sarvarthasadhaka, composed of ten small triangles
-6. Sarva Rakshakara, composed of ten small triangles
-7. Sarva Rohahara, composed of eight small triangles
-8. Sarva siddhi prada, composed of 1 small triangle
-9. Sarvanandamaya, composed of a point or bindu 
-
-> The Sri Chakra (called the Shri Yantra) is the symbol of Hindu tantra, which is based on the Hindu philosophy of Kashmir Shaivism.
-
-
-Vijnanamaya &mdash; spiritual body composed of prayer and fortified by meditation
-
-Anandamaya &mdash; body of the joy of union with god
-
-> &mdash;he who realizes the truth of the body can then come to tknow the truth of the universe
-
-Payodhi-jala &mdash; primordial waters, force of the manifested universe
-
-> A fourth dimension of aesthetic sense, where all is in ourselves, ourselves in all &mdash;Aurobindo
-
-Tantra: analogies between the individual and the cosmos, and the life forces which govern them
-
-> reflections of what is taking place in real life and reminding thought visions of our true nature
-
-
-
-
-
-<img src="media/sriyantra/datta5.jpg" />
-
diff --git a/content/2011/10/alphabet b/content/2011/10/alphabet
deleted file mode 100644 (file)
index dc9d78e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-date = 2011-10-06
-title = alphabet
---
-
-consanants
-
-<img src="media/lang/hindi_cons.gif">
-<br /><br /><br />
-
-vowels
-
-<img src="media/lang/hindi_vwl.gif">
-<br /><br /><br />
-
-numbers
-
-<img src="media/lang/hindi_num.gif">
-<br /><br /><br />
\ No newline at end of file
diff --git a/content/2011/10/dreams b/content/2011/10/dreams
deleted file mode 100644 (file)
index 62e1f08..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-title = dreams
-date = Tue, Oct 4 2011, 12:46:34; IST 
---
-My dreams have been incredibly vivid. probably due to the heat. sleeping at odd hours. been working in the studio most of the day at Vishal's house, so I haven't been going out as much as I would like. It's also incredibly hot outside, averaging about 36 degrees C, which is about 95 F.
\ No newline at end of file
diff --git a/content/2011/10/dushera b/content/2011/10/dushera
deleted file mode 100644 (file)
index 73e05b2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-title = dushera
-date = Sun, Oct 06 2011, 06:00:16 PM; IST
-draft = true
---
-<img src="photos/IMG_1256.jpg" />
-
-dushera
\ No newline at end of file
diff --git a/content/2011/10/islands b/content/2011/10/islands
deleted file mode 100644 (file)
index a762a2e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-title = islands
-date = Wed, Oct 05 2011, 03:53:55 PM; IST
---
-
-> Imagine that every man's mind is an island, surrounded by ocean. Each seems isolated, yet in reality all are linked by the bedrock from which they spring. If the ocean were to vanish, that would be the end of the islands. They would all be part of one continent, but their individuality would be gone.
-
-> &mdash;"The Inspector" Overlord. <u>Childhoods End</u>, Arthur C. Clark. p.176
diff --git a/content/2011/10/overlords b/content/2011/10/overlords
deleted file mode 100644 (file)
index 3ba9abb..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-title = childhoods end
-date = Wed, Oct 05 2011, 03:17:57 PM; IST
---
-
-> The case of India is particularly instructive. The main difference between us and the British in India was that they had no real motives for going there&mdash;no conscious objectives, that is, except such trivial and temporary ones as trade or hostility to other European powers. They found themselves possessors of an empire before they knew what to do with it, and were never really happy until they had got rid of it again.
-
-> &mdash;"The Inspector" Overlord. <u>Childhoods End</u>, Arthur C. Clark. p.161
diff --git a/content/2011/10/smog b/content/2011/10/smog
deleted file mode 100644 (file)
index b5586f1..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-title = sun
-date = Sun, Oct 23 2011, 06:06:33 PM; IST
---
-
-<img src="photos/P1020004.jpg" />
diff --git a/content/2011/10/water_is_life b/content/2011/10/water_is_life
deleted file mode 100644 (file)
index d60a727..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-title = water_is_life
-date = Sun, Oct 23 2011, 06:04:38 PM; IST
-draft = true
---
-
-<img src="photos/P1020037.jpg">
-
-delapitated truck left near the Quotar Minar in Dadabari. Painting on the front bumper reads "Water is Life" in Hindi.
\ No newline at end of file
diff --git a/content/categori1/.DS_Store b/content/categori1/.DS_Store
new file mode 100644 (file)
index 0000000..bcb3407
Binary files /dev/null and b/content/categori1/.DS_Store differ
diff --git a/content/categori1/cat_2/hello_comments b/content/categori1/cat_2/hello_comments
new file mode 100644 (file)
index 0000000..b395a5d
--- /dev/null
@@ -0,0 +1,6 @@
+       
+date = today
+comments = 1
+--
+
+Hello again. Leave some comments.
\ No newline at end of file
diff --git a/content/config b/content/config
deleted file mode 100644 (file)
index 759fb8f..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-template = index
-title = delhi 2011
\ No newline at end of file
diff --git a/content/hello_world b/content/hello_world
new file mode 100644 (file)
index 0000000..24e2111
--- /dev/null
@@ -0,0 +1,5 @@
+title = hello world
+date = nov 10 2011
+--
+
+Hello world.
\ No newline at end of file
diff --git a/css/comments.css b/css/comments.css
new file mode 100644 (file)
index 0000000..d517577
--- /dev/null
@@ -0,0 +1,22 @@
+/* comments.css */
+
+.comments {
+    margin-top:50px;
+}
+.comments textarea {
+       width:315px;
+       height:130px;
+}
+.comments .error {
+       color:#900;
+}
+.comments .comment {
+    margin:20px 0;
+    font-style:italic;
+}
+.comments .comment .name {
+    color:#aaa;
+}
+.comments .comment_form {
+    margin-top:40px;
+}
\ No newline at end of file
index f10980ac64bab19195209b8b3a8ef95dbebf335b..a7d734c560fabddc67d4b0913cdeee88fa5d6462 100644 (file)
@@ -53,7 +53,7 @@ pre {
 }
 
 #content {
-    padding:50px;
+    padding:50px 50px 0 50px;
     background:#fff;
 }
 #nextprev {
@@ -69,6 +69,7 @@ pre {
 
 
 .entry {
+    margin-bottom:80px;
 }
 .entry h2 {
     margin-bottom:20px;
diff --git a/lib/comments.php b/lib/comments.php
new file mode 100644 (file)
index 0000000..1b17db3
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+if (!is_dir($entry['comments_loc'])) {
+       if (!mkdir($entry['comments_loc'], 0775, true)) {
+               echo 'Error making comments directory';
+       }
+}
+
+global $captcha_publickey, $captcha_privatekey;
+
+# the response from reCAPTCHA
+$resp = null;
+# the error code from reCAPTCHA, if any
+$error = null;
+
+# was there a reCAPTCHA response?
+if (isset($_POST["recaptcha_response_field"])) {
+       $resp = recaptcha_check_answer ($captcha_privatekey,
+                                                                       $_SERVER["REMOTE_ADDR"],
+                                    $_POST["recaptcha_challenge_field"],
+                                    $_POST["recaptcha_response_field"]);
+       if ($resp->is_valid) {
+
+               $name    = !empty($_POST['name']) ? $_POST['name'] : 'anon';
+               $www     = !empty($_POST['www']) ? $_POST['www'] : null;
+               $comment = !empty($_POST['comment']) ? $_POST['comment'] : null;
+
+               if (!$comment) {
+
+                       echo '<div class="error">You must enter a comment.</div>';
+
+               } else {
+
+                       $comment = json_encode(array(   
+                               'name'          => $name,
+                               'www'           => $www,
+                               'timestamp'     => date('U'),
+                               'comment'       => $comment));
+                       file_put_contents($entry['comments_loc'] . date('U') . '.json', $comment);
+
+               }
+
+       } else {
+               # set the error code so that we can display it
+               $error = $resp->error;
+       }
+}
+
+echo recaptcha_get_html($captcha_publickey, $error);
index 4ec23d321820fcc255f657379a6ef346ccd396de..c10e4da0b71728e3bce0222a356840c77efad18d 100644 (file)
@@ -25,6 +25,7 @@ function get_entries( $path = "", $args = array())
        $entries = array();
        foreach ($dir_iterator as $file => $info) {
 
+               // mime type
                // $finfo = finfo_open(FILEINFO_MIME_TYPE);
                // $ftype = finfo_file($finfo, join(array($info->getPath(), $info->getFilename()), DIRECTORY_SEPARATOR));
                // finfo_close($finfo);         
@@ -143,21 +144,36 @@ function parse_entry($fileInfo, $page = false)
        }
 
        $f = array();
+
+       $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
+       $clean_path = str_replace(LOCAL_ROOT . CONTENT_DIR, "", clean_slashes($fileInfo->getPath()));
+
        $f['config'] = parse_ini_string($config);
        $f['title'] = isset($f['config']['title']) ? $f['config']['title'] : $fileInfo->getFilename() ;
        $f['config']['date'] = isset($f['config']['date']) ? $f['config']['date'] : null;
        $f['timestamp'] = $f['config']['date'] ? date('U', strtotime( $f['config']['date'])) : $fileInfo->getCTime();
        $f['tags'] = isset($f['config']['tags']) ? explode(" ", $f['config']['tags']) : null;
        $f['content'] = Markdown($content);
+
+       // get comments
+       $f['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
+       $f['comments_loc'] = LOCAL_ROOT . COMMENTS_DIR . $clean_path . DIRECTORY_SEPARATOR . $fileInfo->getFilename() . DIRECTORY_SEPARATOR;
+       $comments = array();
+       if (is_dir($f['comments_loc'])) {
+               $dir_iterator = new DirectoryIterator($f['comments_loc']);
+               foreach ($dir_iterator as $file => $info) {
+                       if (!$info->isDir() && $info->getFilename() != '.' && $info->getFilename() != '..') {
+                               $contents = file_get_contents($info->getPath() . DIRECTORY_SEPARATOR . $info->getFilename());
+                               $comments[] = json_decode($contents, true);
+                       }
+               }
+       }
+       $f['comments'] = $comments;
     
     if ($passed_more)
       $f['content_short'] = Markdown($content_short);
 
-       $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
-       $clean_path = str_replace(LOCAL_ROOT . CONTENT_DIR, "", clean_slashes($fileInfo->getPath()));
-
-       $f['cat'] = $page ? null : array('name' => $clean_path, 'url' => $clean_path );
-       $f['path'] = $fileInfo->getRealPath();
+       $f['cat'] = $page ? null : array('name' => $clean_path, 'url' => $clean_path ); 
        $f['url'] = ($page ? '' : $f['cat']['url'] . '/') . $fileInfo->getFilename();
 
     if (!CLEAN_URLS) {
index 8c030ebdaacbaecf3e4cddf5eb69d542b9776b8b..f26a6196b1100d2b3e5e896b6617b321bc205751 100644 (file)
 
 # error reporting
 error_reporting(E_ALL);
-ini_set("display_errors", 1);
+ini_set('display_errors', 1);
 
 # timezone
-putenv('TZ=Asia/Calcutta');
+putenv('TZ=America/Los_Angeles');
 
 # include path
 ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(realpath(__FILE__)));
@@ -22,10 +22,11 @@ ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(realp
 # settings
 define ('CLEAN_URLS',           false);
 define ('SITE_TITLE',           'india 2011');
-define ('LOCAL_ROOT',           '/Users/gdunne/Sites/india/');
-define ('WEB_ROOT',             '/~gdunne/india/');
+define ('LOCAL_ROOT',           '/Users/gdunne/Sites/quilime/');
+define ('WEB_ROOT',             '/~gdunne/quilime/');
 define ('CONTENT_DIR',                  'content/');
 define ('TEMPLATE_DIR',         'templates/');
+define ('COMMENTS_DIR',         'comments/');
 define ('PAGE_DIR',             'pages/');
 define ('CONFIG_DELIMITER',  '--');
 define ('CONFIG_FILE',                  'config');
@@ -35,9 +36,18 @@ define ('ENTRY_DATE_FORMAT', 'M d Y, h:i:s A T');
 
 $_FILE_IGNORES = array(CONFIG_FILE, '.DS_Store');
 
+
+# recaptcha for comments
+require_once 'recaptchalib.php';
+// Get a key from https://www.google.com/recaptcha/admin/create
+$captcha_publickey  = "6Lek-MkSAAAAAAZknQQGSx9DiCqm_wAiFGytc37d";
+$captcha_privatekey = "6Lek-MkSAAAAAK4FAaPKO0Cwp-iHa0OcUaqipee4";
+
+
 # includes
 require_once 'data.php';
 require_once 'output.php';
 require_once 'markdown.php';
 require_once 'model.php';
-require_once 'view.php';
\ No newline at end of file
+require_once 'view.php';
+
diff --git a/lib/recaptchalib.php b/lib/recaptchalib.php
new file mode 100644 (file)
index 0000000..32c4f4d
--- /dev/null
@@ -0,0 +1,277 @@
+<?php
+/*
+ * This is a PHP library that handles calling reCAPTCHA.
+ *    - Documentation and latest version
+ *          http://recaptcha.net/plugins/php/
+ *    - Get a reCAPTCHA API Key
+ *          https://www.google.com/recaptcha/admin/create
+ *    - Discussion group
+ *          http://groups.google.com/group/recaptcha
+ *
+ * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
+ * AUTHORS:
+ *   Mike Crawford
+ *   Ben Maurer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/**
+ * The reCAPTCHA server URL's
+ */
+define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
+define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
+define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
+
+/**
+ * Encodes the given data into a query string format
+ * @param $data - array of string elements to be encoded
+ * @return string - encoded request
+ */
+function _recaptcha_qsencode ($data) {
+        $req = "";
+        foreach ( $data as $key => $value )
+                $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
+
+        // Cut the last '&'
+        $req=substr($req,0,strlen($req)-1);
+        return $req;
+}
+
+
+
+/**
+ * Submits an HTTP POST to a reCAPTCHA server
+ * @param string $host
+ * @param string $path
+ * @param array $data
+ * @param int port
+ * @return array response
+ */
+function _recaptcha_http_post($host, $path, $data, $port = 80) {
+
+        $req = _recaptcha_qsencode ($data);
+
+        $http_request  = "POST $path HTTP/1.0\r\n";
+        $http_request .= "Host: $host\r\n";
+        $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
+        $http_request .= "Content-Length: " . strlen($req) . "\r\n";
+        $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
+        $http_request .= "\r\n";
+        $http_request .= $req;
+
+        $response = '';
+        if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
+                die ('Could not open socket');
+        }
+
+        fwrite($fs, $http_request);
+
+        while ( !feof($fs) )
+                $response .= fgets($fs, 1160); // One TCP-IP packet
+        fclose($fs);
+        $response = explode("\r\n\r\n", $response, 2);
+
+        return $response;
+}
+
+
+
+/**
+ * Gets the challenge HTML (javascript and non-javascript version).
+ * This is called from the browser, and the resulting reCAPTCHA HTML widget
+ * is embedded within the HTML form it was called from.
+ * @param string $pubkey A public key for reCAPTCHA
+ * @param string $error The error given by reCAPTCHA (optional, default is null)
+ * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
+
+ * @return string - The HTML to be embedded in the user's form.
+ */
+function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
+{
+       if ($pubkey == null || $pubkey == '') {
+               die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
+       }
+       
+       if ($use_ssl) {
+                $server = RECAPTCHA_API_SECURE_SERVER;
+        } else {
+                $server = RECAPTCHA_API_SERVER;
+        }
+
+        $errorpart = "";
+        if ($error) {
+           $errorpart = "&amp;error=" . $error;
+        }
+        return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
+
+       <noscript>
+               <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
+               <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
+               <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
+       </noscript>';
+}
+
+
+
+
+/**
+ * A ReCaptchaResponse is returned from recaptcha_check_answer()
+ */
+class ReCaptchaResponse {
+        var $is_valid;
+        var $error;
+}
+
+
+/**
+  * Calls an HTTP POST function to verify if the user's guess was correct
+  * @param string $privkey
+  * @param string $remoteip
+  * @param string $challenge
+  * @param string $response
+  * @param array $extra_params an array of extra variables to post to the server
+  * @return ReCaptchaResponse
+  */
+function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
+{
+       if ($privkey == null || $privkey == '') {
+               die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
+       }
+
+       if ($remoteip == null || $remoteip == '') {
+               die ("For security reasons, you must pass the remote ip to reCAPTCHA");
+       }
+
+       
+       
+        //discard spam submissions
+        if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
+                $recaptcha_response = new ReCaptchaResponse();
+                $recaptcha_response->is_valid = false;
+                $recaptcha_response->error = 'incorrect-captcha-sol';
+                return $recaptcha_response;
+        }
+
+        $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
+                                          array (
+                                                 'privatekey' => $privkey,
+                                                 'remoteip' => $remoteip,
+                                                 'challenge' => $challenge,
+                                                 'response' => $response
+                                                 ) + $extra_params
+                                          );
+
+        $answers = explode ("\n", $response [1]);
+        $recaptcha_response = new ReCaptchaResponse();
+
+        if (trim ($answers [0]) == 'true') {
+                $recaptcha_response->is_valid = true;
+        }
+        else {
+                $recaptcha_response->is_valid = false;
+                $recaptcha_response->error = $answers [1];
+        }
+        return $recaptcha_response;
+
+}
+
+/**
+ * gets a URL where the user can sign up for reCAPTCHA. If your application
+ * has a configuration page where you enter a key, you should provide a link
+ * using this function.
+ * @param string $domain The domain where the page is hosted
+ * @param string $appname The name of your application
+ */
+function recaptcha_get_signup_url ($domain = null, $appname = null) {
+       return "https://www.google.com/recaptcha/admin/create?" .  _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
+}
+
+function _recaptcha_aes_pad($val) {
+       $block_size = 16;
+       $numpad = $block_size - (strlen ($val) % $block_size);
+       return str_pad($val, strlen ($val) + $numpad, chr($numpad));
+}
+
+/* Mailhide related code */
+
+function _recaptcha_aes_encrypt($val,$ky) {
+       if (! function_exists ("mcrypt_encrypt")) {
+               die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
+       }
+       $mode=MCRYPT_MODE_CBC;   
+       $enc=MCRYPT_RIJNDAEL_128;
+       $val=_recaptcha_aes_pad($val);
+       return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
+}
+
+
+function _recaptcha_mailhide_urlbase64 ($x) {
+       return strtr(base64_encode ($x), '+/', '-_');
+}
+
+/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
+function recaptcha_mailhide_url($pubkey, $privkey, $email) {
+       if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
+               die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
+                    "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
+       }
+       
+
+       $ky = pack('H*', $privkey);
+       $cryptmail = _recaptcha_aes_encrypt ($email, $ky);
+       
+       return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
+}
+
+/**
+ * gets the parts of the email to expose to the user.
+ * eg, given johndoe@example,com return ["john", "example.com"].
+ * the email is then displayed as john...@example.com
+ */
+function _recaptcha_mailhide_email_parts ($email) {
+       $arr = preg_split("/@/", $email );
+
+       if (strlen ($arr[0]) <= 4) {
+               $arr[0] = substr ($arr[0], 0, 1);
+       } else if (strlen ($arr[0]) <= 6) {
+               $arr[0] = substr ($arr[0], 0, 3);
+       } else {
+               $arr[0] = substr ($arr[0], 0, 4);
+       }
+       return $arr;
+}
+
+/**
+ * Gets html to display an email address given a public an private key.
+ * to get a key, go to:
+ *
+ * http://www.google.com/recaptcha/mailhide/apikey
+ */
+function recaptcha_mailhide_html($pubkey, $privkey, $email) {
+       $emailparts = _recaptcha_mailhide_email_parts ($email);
+       $url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
+       
+       return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
+               "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
+
+}
+
+
+?>
index 483451b5f922a49b9fa883c191bc70fdded5c2c8..b4f27b7bcda53e0b44bb09a3e4aecbfc8bae34b7 100644 (file)
@@ -2,6 +2,4 @@ title = about
 --
 
 
-INDIA 2011 is a journal by Gabriel L Dunne, documenting a self-initiated 3mo residiency in Delhi, India with fellow artist Vishal K Dar.
-
-all content &copy; 2011
\ No newline at end of file
+plog CMS by Gabriel L Dunne
\ No newline at end of file
diff --git a/pages/links b/pages/links
deleted file mode 100644 (file)
index 8a3369e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-title = links
-type = page
-markdown = true
---
-people
-------
-+ gabriel dunne [gabrieldunne.com](http://gabrieldunne.com)
-+ stephanie sherriff [ssherriff.com](http://ssherriff.com)
-+ ryan alexander [onecm.com](http://onecm.com)
-+ joshua nimoy [jtnimoy.net](http://jtnimoy.net)
-+ daniel massey [oddsympathy.com](http://oddsympathy.com)
-+ keith pasko [keithpasko.com](http://keithpasko.com)
-+ jeff lubow [dabkitsch.com/jml/](http://dabkitsch.com/jml/)
-+ michael chang [ghost-hack.com](http://ghost-hack.com)  
-+ carbon workshop [carbonworkshop.com](http://carbonworkshop.com)
-+ sascha pohflep [pohflepp.com](http://pohflepp.com)
-+ mylinh trieu [mylinhtrieu.com](http://mylinhtrieu.com)
-+ aaron meyers [universaloscillation.com](http://universaloscillation.com)
-+ tom carden [tom-carden.co.uk](http://tom-carden.co.uk)
-+ michal migurski [mike.teczno.co](http://mike.teczno.com)
-+ adam roth [ripevessel.com](http://ripevessel.com)
-+ david rager [davidrager.org](http://davidrager.org)
-+ marc nimoy [digitanalog.net](http://digitanalog.net)
-+ matthew gale [makaga.com](http://makaga.com)
-+ frédéric eyl [fredericeyl.de](http://fredericeyl.de)
-+ the green eyl [thegreeneyl.com](http://thegreeneyl.com)
-
-<br />
-<br />
-
-places
-------
-+ gray area foundation for the arts [gaffta.org](http://gaffta.org)
-+ bay area video coalition [bavc.org](http://bavc.org)
\ No newline at end of file
diff --git a/templates/comments.html.tpl b/templates/comments.html.tpl
new file mode 100644 (file)
index 0000000..c16fe7c
--- /dev/null
@@ -0,0 +1,30 @@
+<div class="comments">
+
+       <div class="comment_list">
+               
+               <? foreach($entry['comments'] as $comment) : ?>
+               <div class="comment">
+                       <?=$comment['comment'];?>
+                       <div class="name">posted by <?=$comment['name'];?> at <?=$comment['timestamp'];?></div>
+               </div>
+               <? endforeach; ?>
+
+       </div>
+       
+       <div class="comment_form">
+
+    <form action="" method="post">
+    <input type="text" name="name" /> <label for="name">name</label>  <br />
+    <input type="text" name="www" /> <label for="www">www (optional)</label>  <br />
+    <textarea name="comment"></textarea>
+    <br />
+    markdown enabled
+
+       <?php include(LOCAL_ROOT . 'lib/' . 'comments.php'); ?>
+
+    <br/>
+    <input type="submit" value="submit" />
+
+    </form>
+       </div>
+</div>
index 58c3f1744a798dbe4aa4e36b422a8b2271524d5c..bb7c88a2b7b27686a5ecc9e74702706a10588728 100644 (file)
@@ -1,16 +1,24 @@
 <div class="entry">
 
+       <h2><a href="<?=$entry['url']?>"><?=$entry['title']?></a></h2>
+       <div class="metadata">  
+
+       </div>
+
        <div class="content">
                <?=$entry['content']?>
        </div>
 
        <div class="metadata">
-               <a href="<?=$entry['url']?>"><?=$entry['title']?></a>,
-               <span title="<?=get_relative_time($entry['timestamp']);?>"><?=date(ENTRY_DATE_FORMAT, $entry['timestamp'])?></span> 
+               <span title="<?=get_relative_time($entry['timestamp']);?>"><?=date(ENTRY_DATE_FORMAT, $entry['timestamp'])?>
+               <? if (count($entry['comments']) > 0 || $entry['comments_enabled']) : ?>
+               | <a href="<?=$entry['url'];?>#c"><? echo sizeof($entry['comments']) ?> comments</a>
+               <? endif; ?>
+               </span> 
                <? if (!empty($entry['cat']['name'])): ?>
                in <a href="<?=$entry['cat']['url'];?>"><?=$entry['cat']['name'];?></a>
                <br/>
-               <? endif; ?>
+               <? endif; ?>            
                <ul class="tags">
                <? if ($entry['tags']) foreach($entry['tags'] as $tag) : ?>
                <li>#<?=$tag?></li>
@@ -18,4 +26,9 @@
                </ul>
        </div>  
 
+       <? 
+       if ($entry['comments_enabled'])
+               $this->include_template('comments.html.tpl', array('entry' => $entry));
+       ?>
+
 </div>
index ae6fd8ff3050a1b89254f2c19fc1a697ebf99edd..54b9e63c007d9a0e702e6acc0fd101c32ee3052b 100644 (file)
@@ -3,4 +3,5 @@
 
 <link rel="alternate" type="application/rss+xml" title="RSS" href="<?=get_base_dir();?>/.rss" />
 <link rel="stylesheet" href="<?=get_base_dir();?>/css/style.css" type="text/css">
+<link rel="stylesheet" href="<?=get_base_dir();?>/css/comments.css" type="text/css">