public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
* If the path given to upload() does not exist, it will be created.
* Logic tweaks in Page->update()
* Updated the unit tester
* Tweaked post viewing to place an empty <li> in the comments <ol> so we
  can still have AJAX with valid XHTML strict.
* Names can be quoted with backticks to bypass the auto-table-prefixer.
vito (author)
Sat Nov 15 11:46:38 -0800 2008
commit  7266ecf9e8350a23eb169ace2817abfce6713520
tree    ab16c22e6b27b61470edf38e6f6542af7984d9e7
parent  bd73ccd06ceaee6c3f4a5ecf00e4f027b19a26c2
...
424
425
426
427
 
428
429
430
...
456
457
458
 
...
424
425
426
 
427
428
429
430
...
456
457
458
459
0
@@ -424,7 +424,7 @@
0
          */
0
         public static function tablefy(&$field, $tables) {
0
             if (!preg_match_all("/(\(|[\s]+|^)(?!__)([a-z0-9_\.\*]+)(\)|[\s]+|$)/", $field, $matches))
0
-                return;
0
+                return $field = str_replace("`", "", $field); # Method for bypassing the prefixer.
0
 
0
             foreach ($matches[0] as $index => $full) {
0
                 $before = $matches[1][$index];
0
@@ -456,3 +456,4 @@
0
             $field = preg_replace("/AS ([^ ]+)\./i", "AS ", $field);
0
         }
0
     }
0
+
...
929
930
931
 
 
 
 
932
933
934
...
968
969
970
971
 
972
973
 
974
975
976
...
929
930
931
932
933
934
935
936
937
938
...
972
973
974
 
975
976
 
977
978
979
980
0
@@ -929,6 +929,10 @@
0
      */
0
     function upload($file, $extension = null, $path = "", $put = false) {
0
         $file_split = explode(".", $file['name']);
0
+        $dir = MAIN_DIR.Config::current()->uploads_path.$path;
0
+
0
+        if (!file_exists($dir))
0
+            mkdir($dir);
0
 
0
         $original_ext = end($file_split);
0
 
0
@@ -968,9 +972,9 @@
0
         $message = __("Couldn't upload file. CHMOD <code>".MAIN_DIR.Config::current()->uploads_path."</code> to 777 and try again. If this problem persists, it's probably timing out; in which case, you must contact your system administrator to increase the maximum POST and upload sizes.");
0
 
0
         if ($put) {
0
-            if (!@copy($file['tmp_name'], MAIN_DIR.Config::current()->uploads_path.$path.$filename))
0
+            if (!@copy($file['tmp_name'], $dir.$filename))
0
                 error(__("Error"), $message);
0
-        } elseif (!@move_uploaded_file($file['tmp_name'], MAIN_DIR.Config::current()->uploads_path.$path.$filename))
0
+        } elseif (!@move_uploaded_file($file['tmp_name'], $dir.$filename))
0
             error(__("Error"), $message);
0
 
0
         return $filename;
...
149
150
151
152
153
 
 
154
155
 
156
157
158
...
149
150
151
 
 
152
153
154
 
155
156
157
158
0
@@ -149,10 +149,10 @@
0
 
0
             foreach (array("title", "body", "user_id", "parent_id", "show_in_list",
0
                            "list_order", "clean", "url", "created_at", "updated_at") as $attr)
0
-                if ($attr == "updated_at" and $updated_at !== false)
0
-                    $this->$attr = fallback($$attr, datetime());
0
+                if ($attr == "updated_at" and $$attr === null)
0
+                    $this->$attr = $$attr = datetime();
0
                 else
0
-                    $this->$attr = fallback($$attr, $this->$attr);
0
+                    $this->$attr = $$attr = ($$attr !== null ? $$attr : $this->$attr);
0
 
0
             $sql->update("pages",
0
                          array("id" =>           $this->id),
...
127
128
129
130
 
131
132
133
...
127
128
129
 
130
131
132
133
0
@@ -127,7 +127,7 @@
0
             $old = clone $this;
0
 
0
             foreach (array("login", "password", "email", "full_name", "website", "group_id", "joined_at") as $attr)
0
-                $this->$attr = fallback($$attr, $this->$attr); # This sets the $$attr and $this->$attr at the same time.
0
+                $this->$attr = $$attr = ($$attr !== null ? $$attr : $this->$attr);
0
 
0
             $sql->update("users",
0
                          array("id"        => $this->id),
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,7 +4,7 @@ require "rubygems"
0
 require "hpricot"
0
 
0
 `rm -Rfv uploads/*`
0
-`mysql -f --user=root -D chyrp -e 'TRUNCATE TABLE posts; TRUNCATE TABLE post_attributes; TRUNCATE TABLE pages; TRUNCATE TABLE comments; TRUNCATE TABLE tags;' > /dev/null`
0
+`mysql -f --user=root -D chyrp -e 'TRUNCATE TABLE posts; TRUNCATE TABLE post_attributes; TRUNCATE TABLE pages; TRUNCATE TABLE comments;'`
0
 
0
 FUZZER = {
0
   :textarea => "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam urna. Vivamus nisl. Mauris iaculis rutrum elit. Cras ornare congue mi. Nullam mi quam, luctus dapibus, euismod ut, dapibus sed, dui. Praesent est lectus, rutrum ac, blandit vitae, hendrerit at, massa. Morbi mauris purus, lobortis vel, commodo vitae, aliquet vehicula, ante. Nunc commodo. Pellentesque vel lacus. Quisque eros. Maecenas et quam. Curabitur eget justo a ante dignissim dapibus. Sed et lacus. Suspendisse potenti. Vivamus ipsum mi, blandit vitae, scelerisque a, pellentesque vitae, nisl. Donec vitae est et est egestas laoreet. Vestibulum commodo elit ut nisl. Nullam volutpat nisi non elit. Morbi sapien eros, ornare et, dapibus id, mattis id, nibh. Suspendisse ut nisl id est scelerisque faucibus.\n\nPraesent viverra felis nec justo. Duis gravida tempor massa. Aliquam lobortis tortor eu purus. Phasellus volutpat, justo eget molestie rhoncus, nibh tortor suscipit justo, non vehicula tortor tortor id sapien. Vivamus quis nisl et neque ullamcorper viverra. Vestibulum accumsan, elit luctus auctor fermentum, lorem tellus dignissim odio, a lobortis magna nulla eget arcu. Phasellus vel erat at dolor sagittis luctus. Nulla facilisi. In eros eros, molestie sit amet, ornare a, fermentum et, dui. Vivamus vel turpis quis diam iaculis dapibus. Nunc lacinia. Integer commodo, urna interdum imperdiet pretium, libero nulla pellentesque turpis, in ultrices neque tortor at arcu. Sed mollis odio eget mauris ultricies bibendum. Vivamus malesuada metus vel arcu. Nam sit amet metus. Pellentesque quis felis non nibh adipiscing adipiscing.",
...
8
9
10
11
12
13
 
 
 
 
 
14
15
16
...
18
19
20
21
22
23
24
...
8
9
10
 
11
 
12
13
14
15
16
17
18
19
...
21
22
23
 
24
25
26
0
@@ -8,9 +8,12 @@
0
 {% if enabled_modules.comments %}
0
                 <br />
0
                 <h2 class="comments">${ "Comments" | translate }</h2>
0
-                {% if post.comment_count > 0 %}
0
                 <ol class="comments" id="comments_$post.id">
0
-                    {% paginate comment in site.comments_per_page post.comments as comments %}{% include "content/comment.twig" %}{% endpaginate %}
0
+                    {% paginate comment in site.comments_per_page post.comments as comments %}
0
+                    {% include "content/comment.twig" %}
0
+                    {% else %}
0
+                    <li class="no_comments"></li> {# Needed for AJAX commenting and XHTML Strict validation. #}
0
+                    {% endpaginate %}
0
                 </ol>
0
                 <input type="hidden" name="last_comment" value="$post.latest_comment" id="last_comment" />
0
                 $comments.prev_link
0
@@ -18,7 +21,6 @@
0
                 {% if comments.pages > 1 %}
0
                 <span class="pages">${ "Page %d of %d" | translate | format(comments.page, comments.pages) }</span>
0
                 {% endif %}
0
-                {% endif %}
0
                 {% if post.commentable %}
0
                 {% include "forms/comment/new.twig" %}
0
                 {% endif %}

Comments