#saving data in the database $aql = "blog_article {\n \t\t\t\t\tblog_id,\n\t\t\t\t\t\t\t\tauthor__person_id,\n\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\tcontent as article_content,\n\t\t\t\t\t\t\t\tblog_category_id,\n\t\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\t\tactive,\n\t\t\t\t\t\t\t\tmarket_id,\n\t\t\t\t\t\t\t\tintroduction,\n\t\t\t\t\t\t\t\tfeatured,\n\t\t\t\t\t\t\t\tmedia_item_id\n\t\t\t\t\t\t\t\t{$condition}\n\t\t\t\t\t\t\t\torder by blog_article_id DESC\n \t\t\t\t\t}"; aql::save(); $rs_article = aql::select($aql); if (count($_SESSION['blog_article']['tags'])) { foreach ($_SESSION['blog_article']['tags'] as $tag_session_array_id) { $blog_article_id = $article_id; $blog_tag_id = $tag_session_array_id; #search this combination in database $aql_article_tag = "blog_article_tag{\n\t\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\t\twhere blog_article_tag.blog_article_id = '{$blog_article_id}' and blog_article_tag.blog_tag_id = '{$blog_tag_id}'\n\t\t\t\t\t\t\t}"; $rs_article_tag = aql::select($aql_article_tag); if (count($rs_article_tag) > 0) { $blog_article_tag_id = $rs_article_tag[0]['blog_article_tag_id']; $table_name = 'blog_article_tag'; $data_array = array('active' => 0); aql::update($table_name, $data_array, $blog_article_tag_id); } } foreach ($_SESSION['blog_article']['tags'] as $tag_session_array_id) { #inserting each $table_name = 'blog_article_tag'; $data_array = array('blog_article_id' => $article_id, 'blog_tag_id' => $tag_session_array_id); $rs = aql::insert($table_name, $data_array); } } } } #get the blog name if (trim($rs_article[0]['blog_id']) != '') { $blog_id = trim($rs_article[0]['blog_id']); $aql_blog = "blog {\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tslug\n\t\t\t\t\t\t\t\t\t\t\twhere blog.id ='{$blog_id}'\n\t\t\t\t\t\t\t\t\t\t\t}";
<?php $blog_author_ide = $_POST['blog_author_ide']; $blog_author_id = decrypt($blog_author_ide, 'blog_author'); $aql = "\nmarket {\n name as market_name\n where market.primary = 1\n order by name asc\n}"; $markets = aql::select($aql); $new_market_ids = array(); foreach ($markets as $market) { if ($_POST['market_' . $market['market_ide']]) { $new_market_ids[] = $market['market_id']; } } $where = 'market_id not in (' . implode(',', $new_market_ids) . ')'; $aql = "\nblog_author_market{\n market_id\n where blog_author_id={$blog_author_id} and active=1\n}"; //'bam' short for 'blog_author_market' $all_bam = aql::select($aql); if (is_array($all_bam)) { foreach ($all_bam as $bam) { if (!in_array($bam['market_id'], $new_market_ids)) { aql::update('blog_author_market', array('active' => 0), $bam['blog_author_market_id']); } else { unset($new_market_ids[array_search($bam['market_id'], $new_market_ids)]); } } } foreach ($new_market_ids as $new_market_id) { aql::insert('blog_author_market', array('market_id' => $new_market_id, 'blog_author_id' => $blog_author_id)); }
aql::insert('website_uri_data', $data); } } } aql::update('website_page', array('url_specific' => $_POST['val']), $_POST['website_page_id']); //sql("update website_uri_data set on_website = 1 where uri = '".$_POST['uri']."' and website_id = ".$website_id); $aql = "website_uri_data { where uri = '" . $_POST['uri'] . "' and website_id = " . $website_id . "}"; $rs = aql::select($aql); if ($rs) { foreach ($rs as $r) { $website_uri_data = array('on_website' => '1'); $rs = aql::update('website_uri_data', $website_uri_data, $r['website_uri_data_id']); } } ?> <input type="hidden" id="uri_enabled" value="<?php echo $_POST['uri']; ?> " /> <?php } else { //$update = sql("update website_uri_data set on_website = 0 where uri = '".$_POST['uri']."' and website_id = ".$website_id); $aql = "website_uri_data { where uri = '" . $_POST['uri'] . "' and website_id = " . $website_id . "}"; $rs = aql::select($aql); if ($rs) { foreach ($rs as $r) { $website_uri_data = array('on_website' => '0'); $rs = aql::update('website_uri_data', $website_uri_data, $r['website_uri_data_id']); } } }
/** * aql::insert/update on the save array depending on what needs to be done * recursive because of sub objects / queries * @param array $save_array array to save * @param array $ids ids to pass through * @return array updated save array */ private final function saveArray($save_array, $ids = array()) { $is_dev = $this->isDev(); // copy out objects $objects = $save_array['__objects__']; unset($save_array['__objects__']); // helper function $addRecordInfo = function ($table_block, $is_update = false) { $fields = array('update' => array('mod__person_id', 'update__person_id'), 'insert' => array('insert__person_id')); $key = $is_update ? 'update' : 'insert'; $time_field = $key . '_time'; if (!$table_block['fields'][$time_field]) { $table_block['fields'][$time_field] = aql::now(); } if (!defined('PERSON_ID') || !is_numeric(PERSON_ID)) { return $table_block; } $id = PERSON_ID; $fields = $fields[$key]; foreach ($fields as $field) { $table_block['fields'][$field] = $table_block['fields'][$field] ?: $id; } return $table_block; }; foreach ($save_array as $table => $info) { // make sure this is an array $info['fields'] = arrayify($info['fields']); foreach ($ids as $n => $v) { if (is_array($this->_ignore['fields']) && in_array($n, $this->_ignore['fields'])) { // since ids are added to each table in case of foreign keys // abort if they are being ignored in this model continue; } // add the id to the table block iff there are already fields if ($info['fields'] && !$info['fields'][$n]) { $save_array[$table]['fields'][$n] = $v; $info['fields'][$n] = $v; } } if ($info['fields']) { $is_update = $info['id'] && is_numeric($info['id']); $info = $addRecordInfo($info, $is_update); if ($is_update) { aql::update($table, $info['fields'], $info['id'], true); } else { $rs = aql::insert($table, $info['fields'], true); $save_array[$table]['id'] = $info['id'] = $rs[0][$table . '_id']; } } $ids[$table . '_id'] = $info['id']; if (is_array($info['subs'])) { foreach ($info['subs'] as $i => $sub) { $save_array[$table]['subs'][$i] = $this->saveArray($sub, $ids); } } } if (is_array($objects)) { foreach ($objects as $o) { if (!$o['data']) { continue; } $tmp = Model::get($o['object']); $tmp->_data = $o['data']; $tmp->loadIDs($ids); $pt = $tmp->getPrimaryTable(); $pt_id = $pt . '_id'; if (!$tmp->{$pt_id} && $this->{$pt_id}) { $tmp->{$pt_id} = $this->{$pt_id}; } $tmp->save(true); if ($tmp->_errors) { $this->addErrors($tmp->_errors); $this->failTransaction(); } } } $save_array['objects'] = $objects; return $save_array; }
<?php $field = $_POST['field']; $value = $_POST['value']; if (!$value) { $value = ''; } $data[$field] = $value; aql::update('website_page_data', $data, $_POST['sky_ide']); ?> <a class="changeable" ide="<?php echo $_POST['sky_ide']; ?> " field="<?php echo $_POST['field']; ?> "><?php echo $_POST['value'] ? $_POST['value'] : '_________________'; ?> </a>
function login_person($person, $remember_me) { global $cookie_domain; $_SESSION['login']['person_id'] = $person['person_id']; $_SESSION['login']['person_ide'] = encrypt($person['person_id'], 'person'); $_SESSION['login']['fname'] = $person['fname']; $_SESSION['login']['lname'] = $person['lname']; $_SESSION['login']['email'] = $person['email_address']; @setcookie('username', $person['username'], time() + 5184000, '/', $cookie_domain); if ($remember_me) { @setcookie('password', encrypt($person['password']), time() + 5184000, '/', $cookie_domain); } // log this login aql::update('person', array('last_login_time' => 'now()'), $person['person_id']); }
/** * @param int $id */ public function updateDBRecord($id) { // split db_field $dot = strpos($this->params['db_field'], '.'); $table = substr($this->params['db_field'], 0, $dot); $field = substr($this->params['db_field'], $dot + 1); if (!$table || !$field) { $this->errors[] = 'There was an error updating the record for this item. Please contact your system administrator.'; return; } \aql::update($table, array($field => $id), $this->params['db_row_id']); }
<?php $data = array($_POST['field'] => $_POST['value'], 'mod__person_id' => PERSON_ID); $update = aql::update('website_page', $data, $_POST['website_page_ide']); if ($update == true && $_POST['field'] == 'page_type') { exit('success'); } else { if ($update == true && $_POST['field'] == 'nickname') { ?> <a id="name_change" title="Click to Change <?php echo ucwords(str_replace('_', '', $_POST['field'])); ?> "><?php echo $_POST['value']; ?> </a> <?php } else { print_a($update); } }
<?php if ($_POST['func'] == 'updateValue') { $table = $_POST['table']; if (!$table) { exit("Please enter a table name."); } $column = $_POST['column']; if (!$table) { exit("Please enter a column name."); } $id = $_POST['id']; if (!$table) { exit("Please enter an id name."); } $newVal = $_POST['newVal']; if (!$newVal) { $newVal = NULL; } aql::update($table, array($column => $newVal), $id); exit("success"); }
<?php $tab = $tab ? $tab : $_POST['tab']; if (!$media_upload['vfolder_path']) { $media_upload['vfolder_path'] = $_POST['vfolder']; } $blog_article_ide = IDE ? IDE : $_POST['blog_article_ide']; $vfolder = $vfolder ? $vfolder : media::get_vfolder($media_upload['vfolder_path']); if (is_array($vfolder['items'])) { //check if there is a default image. If there is not, set one for blog_article.media_item_id if (!$blog_article) { $blog_article = aql::profile('blog_article', $blog_article); } if (!$blog_article['media_item_id']) { $fields = array('media_item_id' => $vfolder['items'][0]['media_item_id']); aql::update('blog_article', $fields, $blog_article_ide); #echo $vfolder['items'][0]['media_item_id']; $blog_article['media_item_id'] = $vfolder['items'][0]['media_item_id']; $blog_article['media_item_ide'] = $vfolder['items'][0]['media_item_ide']; } //go through each image in this blog's folder foreach ($vfolder['items'] as $item) { $img = media::get_item($item['id'], 100, 100, 0); if ($tab == 'mp3') { include 'pages/admin/blog/post/ajax/mp3-item.php'; } else { include 'item.php'; } } //foreach } else {
<?php $update = aql::update('website_page', array($_POST['field'] => $_POST['value']), $_POST['website_page_ide']); if ($update == true) { ?> <a title="Change <?php echo ucwords(str_replace('_', ' ', $_POST['field'])); ?> " id="<?php echo $_POST['field']; ?> _change" page_ide="<?php echo $_POST['website_page_ide']; ?> " field="<?php echo $_POST['field']; ?> " style="cursor:pointer"><?php echo $_POST['value']; ?> </a> <?php }
#inserting each $table_name = 'blog_article_tag'; $data_array = array('blog_article_id' => $article_id, 'blog_tag_id' => $tag_session_array_id); $rs = aql::insert($table_name, $data_array); } } } } // tweet if new posting in applicable market $age = floor(time() - strtotime($rs_article[0]['post_time'])) / (60 * 60 * 24); if ($rs_article[0]['status'] == 'A' && $age < 2 && !$rs_article[0]['tweet_sent'] && $rs_article[0]['market_id']) { $aql = "market {\n\t\t\t\t\t\t\tslug as market_slug,\n\t\t\t\t\t\t\ttwitter_username,\n\t\t\t\t\t\t\ttwitter_password\n\t\t\t\t\t\t\twhere id = {$rs_article[0]['market_id']}\n\t\t\t\t\t\t}"; $rs = aql::select($aql); $market = $rs[0]; $arr = array('tweet_sent' => 'now()'); aql::update('blog_article', $arr, $rs_article[0]['blog_article_id']); if ($market['twitter_username']) { //tweet include 'lib/class/class.twitter.php'; $t = new Twitter($market['twitter_username'], $market['twitter_password']); $aql = "blog {\n\t\t\t\t\t\t\t\tname as blog_name,\n\t\t\t\t\t\t\t\tslug as blog_slug\n\t\t\t\t\t\t\t\twhere id = {$rs_article[0]['blog_id']}\n\t\t\t\t\t\t\t}"; $rs = aql::select($aql); $blog = $rs[0]; $url = 'http://' . $market['market_slug'] . '.joonbug.com/' . $blog['blog_slug'] . '/' . $rs_article[0]['blog_article_ide']; $tiny_domain = 'joonb.ug'; $tinyurl = uize($url, $tiny_domain); $status_msg = "[{$blog['blog_name']}] {$rs_article[0]['title']}, {$rs_article[0]['introduction']}"; $status_msg = substr($status_msg, 0, 100); $status_msg .= " {$tinyurl}"; $t->updateStatus($status_msg); echo 'Posted to twitter.com/' . $market['twitter_username'] . '<br />';
<?php $article_ide = $_POST['blog_article_id']; $person_id = $_SESSION['login']['person_id']; $table_name = "blog_article"; $data_array = array('active' => 0, 'mod_time' => 'now()', 'mod__person_id' => $person_id); aql::update($table_name, $data_array, $article_ide); header("Location:/admin/blog/article/list/"); exit;
<?php $rs = aql::select("website_page_data { value where website_page_ide = '{$_POST['website_page_ide']}' and field = '{$_POST['field']}' }"); $data = array('value' => $_POST['value'], 'mod__person_id' => PERSON_ID, 'update_time' => 'now()'); if (is_numeric($rs[0]['website_page_data_id'])) { $update = aql::update('website_page_data', $data, $rs[0]['website_page_data_ide']); if ($update == true) { echo 'saved'; } else { echo 'error'; } } else { $data['website_page_id'] = decrypt($_POST['website_page_ide'], 'website_page'); $data['field'] = $_POST['field']; $insert = aql::insert('website_page_data', $data); if (is_numeric($insert['website_page_data_id'])) { echo 'saved'; } else { echo 'error'; } }
<?php $rs = aql::select("website_uri_data { value where website_id = {$_POST['website_id']} and uri = '{$_POST['uri']}' and field = '{$_POST['field']}' }"); if ($rs) { aql::update("website_uri_data", array('on_website' => $_POST['url_specific']), $rs[0]['website_uri_data_id']); } if (!$_POST['url_specific']) { $rs = aql::select("website_page_data { value where field = '{$_POST['field']}' and website_page_id = {$_POST['website_page_id']} }"); } exit($rs[0]['value']);
aql::update('blog_article', $fields, $blog_article_id); exit('Notification has been sent.'); } else { exit('Error: notification template has not been created or notifacation has already been sent.'); } } else { exit("Error: Enter valid target email address."); } } elseif ($func == 'set_blog_media_title') { $title = $_POST['title']; $type = $_POST['type']; $aql = "blog_media\t{\n\t\t\t\t\t\t\twhere media_item_ide = {$media_item_ide}\n\t\t\t\t\t\t\tand type = '{$type}'\n\t\t\t\t\t\t}"; $rs = aql::select($aql); if ($rs) { $fields = array('title' => $title, 'update_time' => 'now()', 'mod__person_id' => $person_id); aql::update('blog_media', $fields, $rs[0]['blog_media_id']); exit('success'); } else { exit('Error: could not find this media file in database.'); } } else { exit('Error: Unrecognized function.'); } } function email($message_text, $subject, $to, $from) { // message $message = "\n\t<html>\n\t<head>\n\t <title>{$subject}</title>\n\t</head>\n\t<body>\n\t {$message_text}\n\t</body>\n\t</html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
<?php if ($_POST['type'] == 'code') { $data = array('value' => $_POST['value']); } else { $data = array('draft' => $_POST['value']); } $update = aql::update("website_page_data", $data, $_POST['website_page_data_id']); if ($update) { ?> <a field="<?php echo $_POST['field']; ?> " type="draft" wpd_id="<?php echo $_POST['website_page_data_id']; ?> " style="cursor:pointer" class="compare_edit"><?php echo $_POST['value'] ? $_POST['value'] : 'N/A'; ?> </a> <?php }