diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2008-12-13 10:01:56 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2008-12-13 10:01:56 -0500 |
commit | 7eb055141bae63b85cef93e5d6f67e3016219d7b (patch) | |
tree | a688d1cb452ea8a2bcf6f278326b2a36e8e03fd3 /pages/admin.php | |
parent | 391f6825d7b5bc986d6529b2a2a4c043555d9f07 (diff) | |
download | fourisland-7eb055141bae63b85cef93e5d6f67e3016219d7b.tar.gz fourisland-7eb055141bae63b85cef93e5d6f67e3016219d7b.tar.bz2 fourisland-7eb055141bae63b85cef93e5d6f67e3016219d7b.zip |
Optimized posting
Previously, Four Island posted a blog, and then searched through the table looking for it so it could retrieve its ID. Now, the "mysql_insert_id()" function is used instead.
Diffstat (limited to 'pages/admin.php')
-rwxr-xr-x | pages/admin.php | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/pages/admin.php b/pages/admin.php index b21948c..aff21cf 100755 --- a/pages/admin.php +++ b/pages/admin.php | |||
@@ -44,24 +44,21 @@ if (isLoggedIn()) | |||
44 | $insdraft = "INSERT INTO drafts (title,author,text,slug) VALUES (\"" . addslashes($_POST['title']) . "\",\"" . sess_get('uname') . "\",\"" . addslashes($_POST['text']) . "\",\"" . generateSlug($_POST['title'],'updates') . "\")"; | 44 | $insdraft = "INSERT INTO drafts (title,author,text,slug) VALUES (\"" . addslashes($_POST['title']) . "\",\"" . sess_get('uname') . "\",\"" . addslashes($_POST['text']) . "\",\"" . generateSlug($_POST['title'],'updates') . "\")"; |
45 | $insdraft2 = mysql_query($insdraft); | 45 | $insdraft2 = mysql_query($insdraft); |
46 | 46 | ||
47 | $getdraft = "SELECT * FROM drafts ORDER BY id DESC LIMIT 0,1"; | 47 | $id = mysql_insert_id(); |
48 | $getdraft2 = mysql_query($getdraft); | 48 | addTags($id, $tags, 'draft'); |
49 | $getdraft3 = mysql_fetch_array($getdraft2); | ||
50 | |||
51 | addTags($getdraft3['id'], $tags, 'draft'); | ||
52 | 49 | ||
53 | $template = new FITemplate('admin/draftSuccess'); | 50 | $template = new FITemplate('admin/draftSuccess'); |
54 | $template->add('ID', $getdraft3['id']); | 51 | $template->add('ID', $id); |
55 | } else if ($_POST['type'] == 'instant') | 52 | } else if ($_POST['type'] == 'instant') |
56 | { | 53 | { |
57 | postBlogPost($_POST['title'], sess_get('uname'), $tags, $_POST['text']); | 54 | $id = postBlogPost($_POST['title'], sess_get('uname'), $tags, $_POST['text']); |
58 | 55 | ||
59 | $getpost = "SELECT * FROM updates ORDER BY id DESC LIMIT 0,1"; | 56 | $getpost = "SELECT * FROM updates WHERE id = " . $id; |
60 | $getpost2 = mysql_query($getpost); | 57 | $getpost2 = mysql_query($getpost); |
61 | $getpost3 = mysql_fetch_array($getpost2); | 58 | $getpost3 = mysql_fetch_array($getpost2); |
62 | 59 | ||
63 | $template = new FITemplate('admin/postSuccess'); | 60 | $template = new FITemplate('admin/postSuccess'); |
64 | $template->add('ID', $getpost3['id']); | 61 | $template->add('ID', $id); |
65 | $template->add('CODED', $getpost3['slug']); | 62 | $template->add('CODED', $getpost3['slug']); |
66 | } else { | 63 | } else { |
67 | if ($_POST['type'] == 'normal') | 64 | if ($_POST['type'] == 'normal') |
@@ -143,17 +140,17 @@ if (isLoggedIn()) | |||
143 | $template->add('ID', $_GET['id']); | 140 | $template->add('ID', $_GET['id']); |
144 | } else if ($_POST['type'] == 'instant') | 141 | } else if ($_POST['type'] == 'instant') |
145 | { | 142 | { |
146 | postBlogPost($_POST['title'], sess_get('uname'), $tags, $_POST['text']); | 143 | $id = postBlogPost($_POST['title'], sess_get('uname'), $tags, $_POST['text']); |
147 | 144 | ||
148 | $deldraft = "DELETE FROM drafts WHERE id = " . $_GET['id']; | 145 | $deldraft = "DELETE FROM drafts WHERE id = " . $_GET['id']; |
149 | $deldraft2 = mysql_query($deldraft); | 146 | $deldraft2 = mysql_query($deldraft); |
150 | 147 | ||
151 | $getpost = "SELECT * FROM updates ORDER BY id DESC LIMIT 0,1"; | 148 | $getpost = "SELECT * FROM updates WHERE id = " . $id; |
152 | $getpost2 = mysql_query($getpost); | 149 | $getpost2 = mysql_query($getpost); |
153 | $getpost3 = mysql_fetch_array($getpost2); | 150 | $getpost3 = mysql_fetch_array($getpost2); |
154 | 151 | ||
155 | $template = new FITemplate('admin/postSuccess'); | 152 | $template = new FITemplate('admin/postSuccess'); |
156 | $template->add('ID', $getpost3['id']); | 153 | $template->add('ID', $id); |
157 | $template->add('CODED', $getpost3['slug']); | 154 | $template->add('CODED', $getpost3['slug']); |
158 | } else { | 155 | } else { |
159 | if ($_POST['type'] == 'normal') | 156 | if ($_POST['type'] == 'normal') |