<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -58,14 +58,26 @@ class Shortcore {
         $this-&gt;handle();
     }
 
+    function exec($sql, $array) {
+        try {
+            $q = $this-&gt;db-&gt;prepare($sql, array(PDO::ATTR_CURSOR =&gt; PDO::CURSOR_FWDONLY));
+            $q-&gt;execute($array);
+        } catch (Exception $e) {
+            $q = false;
+        }
+        return $q;
+    }
+
+
     /**
      * Grabs a result from the database
      * @param string $id the desired id
      * @return mixed
      */
     function getResult($id) {
-        $sql_select = sprintf('SELECT * FROM %s WHERE id=&quot;%s&quot;', $this-&gt;cfg['table'], $id);
-        $q = $this-&gt;db-&gt;query($sql_select);
+        $sql_select = sprintf('SELECT * FROM %s WHERE id=:id', $this-&gt;cfg['table']);
+        $q = $this-&gt;exec($sql_select, array(':id' =&gt; $id));
+
         if ($q === false) {
             $result = false;
         } else {
@@ -85,21 +97,20 @@ class Shortcore {
             $id = substr($id, 0, -1);
         }
         $result = $this-&gt;getResult($id);
-        if (is_null($result) || false === $result) {
+        if (false === $result) {
             $this-&gt;page();
         } else {
             $counter = intval($result['counter']) + 1;
-            $sql_update  = sprintf('UPDATE %s SET counter=&quot;%s&quot; WHERE id=&quot;%s&quot;;', $this-&gt;cfg['table'], $counter, $id);
-            $p = $this-&gt;db-&gt;query($sql_update);
-                if ($this-&gt;DEBUG) var_dump($p);
-                if ($this-&gt;DEBUG) var_dump($this-&gt;db-&gt;errorInfo());
+            $sql_update  = sprintf('UPDATE %s SET counter=&quot;%s&quot; WHERE id=:id;', $this-&gt;cfg['table'], $counter);
+            $p = $this-&gt;exec($sql_update, array(':id' =&gt; $id));
+
             if ($preview) {
                 $link1 = sprintf('&lt;a href=&quot;%s_%s&quot;&gt;%s_%s&lt;/a&gt;', $this-&gt;cfg['home'], $id, $this-&gt;cfg['home'], $id);
                 $link2 = sprintf('&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', $result['url'], $result['url']);
                 $text = sprintf('The link you clicked on, &lt;em&gt;%s&lt;/em&gt;, is a redirect to &lt;strong&gt;%s&lt;/strong&gt;,&lt;br /&gt;'.
                                 ' was shortened on &lt;em&gt;%s&lt;/em&gt; and has been clicked %s times.', 
-                    $link1, $link2, date('d.m.Y H:i',$result['created']), $counter);
-                echo sprintf($this-&gt;cfg['tpl_body'],$text);
+                                $link1, $link2, date('d.m.Y H:i', $result['created']), $counter);
+                echo sprintf($this-&gt;cfg['tpl_body'], $text);
             } else {
                 $this-&gt;page($result['url']);
             }
@@ -138,10 +149,9 @@ class Shortcore {
         if (is_null($title)) {
             $title = 'untitled';
         }
-        $sql_insert = sprintf('INSERT INTO %s VALUES(&quot;%s&quot;, &quot;%s&quot;, &quot;%s&quot;, 0, &quot;%s&quot;);', 
-                                $this-&gt;cfg['table'], $id, $url, $title, $time);
-            if ($this-&gt;DEBUG) print_r($sql_insert);
-        $this-&gt;db-&gt;query($sql_insert);
+        $sql_insert = sprintf('INSERT INTO %s VALUES(:id, :url, :title, 0, &quot;%s&quot;);', 
+                                $this-&gt;cfg['table'], $time);
+        $this-&gt;exec($sql_insert, array(':id' =&gt; $id, ':url' =&gt; $url, ':title' =&gt; $title));
         $this-&gt;page($cfg['home'].'_'.$id.'_');
     }
 
@@ -187,13 +197,13 @@ class Shortcore {
 
         // writing
         if (!is_null($_url)) {
-            $this-&gt;_e('adding');
+            $this-&gt;_e('adding:'.$_id);
             $this-&gt;add($_id, $_url, $_title);
         // reading
         } else {
             // this is &quot;/_&lt;id&gt;&quot;
             if (!is_null($_id)) {
-                $this-&gt;_e('redir');
+                $this-&gt;_e('redir:'.$_id);
                 $this-&gt;redirect($_id);
             }
         }</diff>
      <filename>shortcore.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>918cbe47ad225d72c979ddcd7a51c652b20177f9</id>
    </parent>
  </parents>
  <author>
    <name>Florian Anderiasch</name>
    <email>fa@art-core.org</email>
  </author>
  <url>http://github.com/winks/shortcore/commit/53de3c5377a3c36df38fa1d3512fcffd246db34e</url>
  <id>53de3c5377a3c36df38fa1d3512fcffd246db34e</id>
  <committed-date>2009-07-03T01:24:22-07:00</committed-date>
  <authored-date>2009-07-03T01:24:22-07:00</authored-date>
  <message>forgot the prepared statement patch</message>
  <tree>a327ad499775221a3099ca96b9c9bb6fb248c563</tree>
  <committer>
    <name>Florian Anderiasch</name>
    <email>fa@art-core.org</email>
  </committer>
</commit>
