$tosave[] = $new; //var_dump ( $k ); // var_dump ( $v ); //print "<hr>"; } foreach ($tosave as $item) { $cfs = $item['cf']; $cfkeys = array_keys($item['cf']); foreach ($cfkeys as $cfkey) { foreach ($cfs as $cfs_k => $cfs_v) { if (strtolower($cfkey) == strtolower($cfs_k)) { //p($cfs_v); $vv = array_values_recursive($cfs_v); //p($vv); $cfs_k = strtolower($cfs_k); $post = array(); $post['id'] = $item['id']; $post['custom_field_' . $cfs_k] = implode(',', $vv); $saved = post_save($post); //print $cfs_k . implode ( ',', $vv ); p($post); print "<hr>"; } } } //p ( $cfkeys ); } } //var_dump ( $k ); } else { }
function save_post() { $id = user_id(); if ($id == 0) { exit('Error: not logged in.'); } $id = is_admin(); if ($id == false) { exit('Error: not logged in as admin.'); } if ($_POST) { $save = post_save($_POST); $save = json_encode($save); print $save; exit; } }
function form_msg() { echo "<br /><br />\n"; form_dump(array('receiver' => array('select', 'SELECT user FROM users;'), 'message' => array('textarea', '', '*'), 'files' => array('mselect', 'SELECT fid FROM files;'), 'send' => array('submit', 'submit'))); } if (isset($_GET['newmsg']) && $_GET['newmsg'] == 1) { echo 'Compose new message' . "<br />\n"; form_msg(); } else { if (!empty($_POST)) { if (is_numeric($receiver)) { $tou = $receiver; } else { $tou = user2id($receiver); } if (post_save(get_login_id(), $tou, $message)) { echo 'Message successfully saved!<br />'; } else { echo ' Problem saving message ... Try again please.<br />'; } form_msg(); echo '<br /><br />' . "\n"; unset($_GET); unset($_POST); echo '<a href="' . $_SERVER['PHP_SELF'] . '">Return to overview</a><br />' . "\n"; } else { if (!isset($uid)) { $uid = get_login_id(); } $q = "SELECT * FROM msgs WHERE to_id='" . sqlite_escape_string($uid) . "'"; $res = db_fetch_array(db_query($q), SQLITE_ASSOC);