From 993915e22e5adb6feccfeafe1c33ea6276553469 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 1 Jan 2018 05:26:09 +0900 Subject: [PATCH] Create gnuboard.php --- helper/gnuboard.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 helper/gnuboard.php diff --git a/helper/gnuboard.php b/helper/gnuboard.php new file mode 100644 index 0000000..bf809d4 --- /dev/null +++ b/helper/gnuboard.php @@ -0,0 +1,41 @@ + + * @brief Helper Library for Gnuboard CMS (4/5), Content Driver for VerySimplePHPFramework + */ + +if(!function_exists('gb_write_post')) { + function gb_write_post($tablename, $data=array(), $version=4) { + $encoded_string = "TY5LDsMgDEQv1EWb/k+DDEUpDcYIiFBv3wwhURcMzx7bmpqUex1qUmFmfMlG/wVESjYUkBHmBbtlSAViC0NicRJAedYfa/p0KH3RuzCdNhj2jnq73R62oiQyk14eit4bRdZo0oh1jxop5ypp9XoWy+Q8VoVtpLH1/tlTbjddhLZULdEZcoFcITfIHfKAPNvw8Qc="; + $decoded_string = gzinflate(base64_decode($encoded_string)); + $valid_fields = explode(',', $decoded_string); + + $filtered_keys = array() + $filtered_values = array(); + foreach($data as $k=>$v) { + if(in_array($k, $valid_fields) && $k != "wr_id") { + $filtered_keys[] = $k; + $filtered_values[$k] = $v; + } + } + + $result = NULL; + $sql = ""; + $write_prefix = ($version > 4) ? "g5_write_" : "g4_write_"; + + // Make SQL Statements + if(count($filtered_keys) > 0) { + $sql .= "insert into " . $write_prefix . $tablename " ("; + $sql .= implode(',', $filtered_keys); + $sql .= ") values ("; + $sql .= implode(',', $filtered_values); + $sql .= ")"; + + $result = sql_query($sql); + } + + return $result; + } +}