[Comoblog-commit] modules/mod_fortune_db/include mod_fortune_db.inc.php, 1.3, 1.4
Status: Inactive
Brought to you by:
markwallis
|
From: iamdecal <iam...@us...> - 2006-10-22 11:44:51
|
Update of /cvsroot/comoblog/modules/mod_fortune_db/include In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27709/modules/mod_fortune_db/include Modified Files: mod_fortune_db.inc.php Log Message: work in progress, ditching this server cos its borked ;( Index: mod_fortune_db.inc.php =================================================================== RCS file: /cvsroot/comoblog/modules/mod_fortune_db/include/mod_fortune_db.inc.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mod_fortune_db.inc.php 16 Feb 2006 14:22:19 -0000 1.3 +++ mod_fortune_db.inc.php 22 Oct 2006 11:44:17 -0000 1.4 @@ -1,106 +1,106 @@ -<?php - -function mod_fortune_db() - { - $query = "select fortune_db_id, fortune_db_content from ".CFG_MYSQL_TABPREFIX."mod_fortune_db order by rand() limit 1 "; - $res = mysql_query($query); - $query = "update ".CFG_MYSQL_TABPREFIX."mod_fortune_db set fortune_db_display_count = (fortune_db_display_count +1) where fortune_db_id =". addslashes(mysql_result($res, 0,0)) ; - $res2 = mysql_query($query); - return mysql_result($res, 0,1); - } - - - - -function mod_fortune_db_details ($item_id) { - $query = "select * from ".CFG_MYSQL_TABPREFIX."mod_fortune_db where fortune_db_id = '".$item_id."'"; - $res = mysql_query($query); - - if (!$res || !mysql_num_rows($res)) - return (false); - - $item = mysql_fetch_assoc($res); - - return ($item); -} - - -function mod_fortune_db_list () { - $query = " - select b.* - from ".CFG_MYSQL_TABPREFIX."mod_fortune_db b - order by b.fortune_db_content - "; - $res = mysql_query($query); - - if (!$res || !mysql_num_rows($res)) - return (false); - - $items = array(); - while ($row = mysql_fetch_assoc($res)) - { - $items[] = $row; - } - return ($items); -} - -function mod_fortune_db_add ($item) { - - $query = "select max(fortune_db_display_order)+1 from ".CFG_MYSQL_TABPREFIX."mod_fortune_db"; - $res = mysql_query($query); - $item['fortune_db_display_order'] = mysql_result($res,0,0); - - $item['fortune_db_added'] = time(); - - $query = " - insert into ".CFG_MYSQL_TABPREFIX."mod_fortune_db - ( fortune_db_content, fortune_db_display_count, fortune_db_display_order, fortune_db_added) - values ('". $item['fortune_db_content'] ."', - '". $item['fortune_db_display_count'] ."', - '". $item['fortune_db_display_order']."', - '". $item['fortune_db_added'] ."') - "; - $res = mysql_query($query); - - if (!$res) - return (false); - - $item['id'] = mysql_insert_id(); - - return ($item); -} - -function mod_fortune_db_del ($item_id) { - $query = "delete from ".CFG_MYSQL_TABPREFIX."mod_fortune_db where fortune_db_id = '".$item_id."'"; - $res = mysql_query($query); - - if (!$res) - return (false); - - return (true); -} - -function mod_fortune_db_edit ($item) { - $query = " - update ".CFG_MYSQL_TABPREFIX."mod_fortune_db - set fortune_db_content = '". $item['fortune_db_content'] ."', - fortune_db_display_count = '". $item['fortune_db_display_count'] ."', - fortune_db_display_order = '". $item['fortune_db_display_order']."' - where - fortune_db_id = '". $item['fortune_db_id'] ."' - "; - $res = mysql_query($query); - - if (!$res) - return (false); - - return ($item); -} - -function mod_fortune_db_up ($item_id) { - -} - -function mod_fortune_db_down ($item_id) { - -} +<?php + +function mod_fortune_db() + { + $query = "select fortune_db_id, fortune_db_content from ".CFG_MYSQL_TABPREFIX."mod_fortune_db order by rand() limit 1 "; + $res = mysql_query($query); + $query = "update ".CFG_MYSQL_TABPREFIX."mod_fortune_db set fortune_db_display_count = (fortune_db_display_count +1) where fortune_db_id =". addslashes(mysql_result($res, 0,0)) ; + $res2 = mysql_query($query); + return mysql_result($res, 0,1); + } + + + + +function mod_fortune_db_details ($item_id) { + $query = "select * from ".CFG_MYSQL_TABPREFIX."mod_fortune_db where fortune_db_id = '".$item_id."'"; + $res = mysql_query($query); + + if (!$res || !mysql_num_rows($res)) + return (false); + + $item = mysql_fetch_assoc($res); + + return ($item); +} + + +function mod_fortune_db_list () { + $query = " + select b.* + from ".CFG_MYSQL_TABPREFIX."mod_fortune_db b + order by b.fortune_db_content + "; + $res = mysql_query($query); + + if (!$res || !mysql_num_rows($res)) + return (false); + + $items = array(); + while ($row = mysql_fetch_assoc($res)) + { + $items[] = $row; + } + return ($items); +} + +function mod_fortune_db_add ($item) { + + $query = "select max(fortune_db_display_order)+1 from ".CFG_MYSQL_TABPREFIX."mod_fortune_db"; + $res = mysql_query($query); + $item['fortune_db_display_order'] = mysql_result($res,0,0); + + $item['fortune_db_added'] = time(); + + $query = " + insert into ".CFG_MYSQL_TABPREFIX."mod_fortune_db + ( fortune_db_content, fortune_db_display_count, fortune_db_display_order, fortune_db_added) + values ('". $item['fortune_db_content'] ."', + '". $item['fortune_db_display_count'] ."', + '". $item['fortune_db_display_order']."', + '". $item['fortune_db_added'] ."') + "; + $res = mysql_query($query); + + if (!$res) + return (false); + + $item['id'] = mysql_insert_id(); + + return ($item); +} + +function mod_fortune_db_del ($item_id) { + $query = "delete from ".CFG_MYSQL_TABPREFIX."mod_fortune_db where fortune_db_id = '".$item_id."'"; + $res = mysql_query($query); + + if (!$res) + return (false); + + return (true); +} + +function mod_fortune_db_edit ($item) { + $query = " + update ".CFG_MYSQL_TABPREFIX."mod_fortune_db + set fortune_db_content = '". $item['fortune_db_content'] ."', + fortune_db_display_count = '". $item['fortune_db_display_count'] ."', + fortune_db_display_order = '". $item['fortune_db_display_order']."' + where + fortune_db_id = '". $item['fortune_db_id'] ."' + "; + $res = mysql_query($query); + + if (!$res) + return (false); + + return ($item); +} + +function mod_fortune_db_up ($item_id) { + +} + +function mod_fortune_db_down ($item_id) { + +} |