function saveAction() { $db = front::og("db"); $save = front::toWin(array("title" => front::$_req["form"]["title"], "msg" => front::$_req["form"]["msg"], "id_blog" => 0, "id_user" => $_SESSION["uid"])); if (intval($id = front::$_req["id"]) > 0) { $aff = $db->update("UPDATE corporative_blog SET ?s WHERE (id = ?n)", $save, $id); } else { $id = $db->insert("corporative_blog", $save); } echo json_encode(array("success" => true, "id" => $id)); }
function saveAction() { $db = front::og("db"); $save = front::toWin(array("name" => front::$_req["form"]["name"], "login" => front::$_req["form"]["login"], "occupation" => front::$_req["form"]["occupation"], "email" => front::$_req["form"]["email"], "icq" => front::$_req["form"]["icq"], "skype" => front::$_req["form"]["skype"], "login" => front::$_req["form"]["login"], "groupid" => front::$_req["form"]["groupid"], "additional" => front::$_req["form"]["additional"])); if (intval($id = front::$_req["id"]) > 0) { $aff = $db->update("UPDATE team_people SET ?s WHERE (id = ?n)", $save, $id); } else { $id = $db->insert("team_people", $save); } echo json_encode(array("success" => true, "id" => $id)); }
function editRadzelAction() { $db = front::og("db"); $save = front::toWin(array("name" => front::$_req["title"])); if (intval($id = front::$_req["id"]) > 0) { $aff = $db->update("UPDATE faq_category SET ?s WHERE (id = ?n)", $save, $id); } else { $id = $db->insert("faq_category", $save); } echo json_encode(array("success" => true, "id" => $id)); }
public function saveAction() { $db = front::og('db'); $save = front::toWin(array('header' => front::$_req['form']['header'], 'n_text' => front::$_req['form']['n_text'], 'post_date' => front::$_req['form']['post_date'])); if (intval($id = front::$_req['id']) > 0) { $aff = $db->update('UPDATE news SET ?s WHERE (id = ?n)', $save, $id); } else { $id = $db->insert('news', $save); } echo json_encode(array('success' => true, 'id' => $id)); }
public function saveAction() { $db = front::og('db'); $save = front::toWin(array('title' => front::$_req['form']['title'], 'msg' => front::$_req['form']['msg'], 'id_blog' => 0, 'id_user' => $_SESSION['uid'])); if (intval($id = front::$_req['id']) > 0) { $aff = $db->update('UPDATE corporative_blog SET ?s WHERE (id = ?n)', $save, $id); } else { $id = $db->insert('corporative_blog', $save); } echo json_encode(array('success' => true, 'id' => $id)); }
function saveAction() { $db = front::og("db"); $save = front::toWin(array("header" => front::$_req["form"]["header"], "n_text" => front::$_req["form"]["n_text"], "post_date" => front::$_req["form"]["post_date"])); if (intval($id = front::$_req["id"]) > 0) { $aff = $db->update("UPDATE news SET ?s WHERE (id = ?n)", $save, $id); } else { $id = $db->insert("news", $save); } echo json_encode(array("success" => true, "id" => $id)); }
public function saveAction() { $db = front::og('db'); $save = front::toWin(array('name' => front::$_req['form']['name'], 'login' => front::$_req['form']['login'], 'occupation' => front::$_req['form']['occupation'], 'email' => front::$_req['form']['email'], 'icq' => front::$_req['form']['icq'], 'skype' => front::$_req['form']['skype'], 'login' => front::$_req['form']['login'], 'groupid' => front::$_req['form']['groupid'], 'additional' => front::$_req['form']['additional'])); if (intval($id = front::$_req['id']) > 0) { $aff = $db->update('UPDATE team_people SET ?s WHERE (id = ?n)', $save, $id); } else { $id = $db->insert('team_people', $save); } echo json_encode(array('success' => true, 'id' => $id)); }
public function editRadzelAction() { $db = front::og('db'); $save = front::toWin(array('name' => front::$_req['title'])); if (intval($id = front::$_req['id']) > 0) { $aff = $db->update('UPDATE faq_category SET ?s WHERE (id = ?n)', $save, $id); } else { $id = $db->insert('faq_category', $save); } echo json_encode(array('success' => true, 'id' => $id)); }
function saveAction() { $db = front::og("db"); $save = front::toWin(array("msgtext" => front::$_req["form"]["msgtext"], "sign" => front::$_req["form"]["sign"], "link" => front::$_req["form"]["link"], "logo" => page_admin_flash_upload2::getFileValue(front::$_req["form"]["logo"], "about/opinions/"))); // foreach($save as &$one) { $one = ($one);} if (intval($id = front::$_req["id"]) > 0) { $aff = $db->update("UPDATE sopinions SET ?s WHERE (id = ?n)", $save, $id); } else { $id = $db->insert("sopinions", $save); } echo json_encode(array("success" => true, "id" => $id)); }
public function editRadzelAction() { $db = front::og('db'); $save = front::toWin(array('title' => front::$_req['title'])); if (intval($id = front::$_req['id']) > 0) { $aff = $db->update('UPDATE team_groups SET ?s WHERE (id = ?n)', $save, $id); } else { team::CreateGroup(front::$_req['title']); //$id = $db->insert("team_groups", $save); } echo json_encode(array('success' => true, 'id' => $id)); }
function editRadzelAction() { $db = front::og("db"); $save = front::toWin(array("title" => front::$_req["title"])); if (intval($id = front::$_req["id"]) > 0) { $aff = $db->update("UPDATE team_groups SET ?s WHERE (id = ?n)", $save, $id); } else { team::CreateGroup(front::$_req["title"]); //$id = $db->insert("team_groups", $save); } echo json_encode(array("success" => true, "id" => $id)); }
public function saveAction() { $db = front::og('db'); $save = front::toWin(array('msgtext' => front::$_req['form']['msgtext'], 'sign' => front::$_req['form']['sign'], 'link' => front::$_req['form']['link'], 'logo' => page_admin_flash_upload2::getFileValue(front::$_req['form']['logo'], 'about/opinions/'))); // foreach($save as &$one) { $one = ($one);} if (intval($id = front::$_req['id']) > 0) { $aff = $db->update('UPDATE sopinions SET ?s WHERE (id = ?n)', $save, $id); } else { $id = $db->insert('sopinions', $save); } echo json_encode(array('success' => true, 'id' => $id)); }
public function saveAction() { $db = front::og('db'); $save = front::toWin(array('title' => front::$_req['form']['title'], 'n_text' => front::$_req['form']['n_text'])); if ($id = front::$_req['id']) { $aff = $db->update('UPDATE static_pages SET ?s WHERE (alias = ?)', $save, $id); if (!$aff) { $save['alias'] = $id; $db->insert('static_pages', $save, false); } } echo json_encode(array('success' => true, 'id' => $id)); }
function saveAction() { $db = front::og("db"); $save = front::toWin(array("title" => front::$_req["form"]["title"], "n_text" => front::$_req["form"]["n_text"])); if ($id = front::$_req["id"]) { $aff = $db->update("UPDATE static_pages SET ?s WHERE (alias = ?)", $save, $id); if (!$aff) { $save["alias"] = $id; $db->insert("static_pages", $save, false); } } echo json_encode(array("success" => true, "id" => $id)); }
/** * Обновить посты которые юзер посмотрел, для того чтобы в след раз когда он зашел он видел есть ли новые комментарии к посту * * @param integer $bid ИД поста * @param unknown_type $date дата последнего просмотра (UNIX_TIME) * @return array [дата, ИД] */ function updViewPost($bid, $date = false, $count = 0) { if (!$date) { $date = date('c'); } $save = front::toWin(array("uid" => get_uid(), "blog_id" => $bid, "date_view" => $date, "v_count" => intval($count))); list($date, $id) = self::getViewPost(get_uid(), $bid); if ($id) { $aff = front::og("db")->update("UPDATE corporative_blog_update SET ?s WHERE (id = ?n)", $save, $id); } else { $id = front::og("db")->insert("corporative_blog_update", $save); } return array($date, $id); }
/** * Обновить посты которые юзер посмотрел, для того чтобы в след раз когда он зашел он видел есть ли новые комментарии к посту. * * @param int $bid ИД поста * @param unknown_type $date дата последнего просмотра (UNIX_TIME) * * @return array [дата, ИД] */ public function updViewPost($bid, $date = false, $count = 0) { if (!$date) { $date = date('c'); } $save = front::toWin(array('uid' => get_uid(), 'blog_id' => $bid, 'date_view' => $date, 'v_count' => intval($count))); list($date, $id) = self::getViewPost(get_uid(), $bid); if ($id) { $aff = front::og('db')->update('UPDATE corporative_blog_update SET ?s WHERE (id = ?n)', $save, $id); } else { $id = front::og('db')->insert('corporative_blog_update', $save); } return array($date, $id); }
public function saveAction() { $db = front::og('db'); $form = front::$_req['form']; $id_comm = front::$_req['comment']; $parent = front::$_req['parent']; if (!$id_comm) { $id_comm = false; } // global $session; $validate_errors = array(); $save = array(); if (($str = trim($form['title'])) && mb_strlen($str) >= 3) { $save['title'] = change_q_x_a(antispam($str), 0, 96); } else { $validate_errors['title'] = 'Заголовок короче 3 символов'; } if (($str = trim($form['msg'])) && mb_strlen($str) >= 3) { $save['msg'] = change_q_x_a(antispam($str), false, false); } else { $validate_errors['msg'] = 'Текст короче 3 символов'; } if (strlen($form['msg']) > blogs::MAX_DESC_CHARS) { $validate_errors['msg'] = 'Максимальный размер сообщения ' . blogs::MAX_DESC_CHARS . ' символов!'; } else { $save['msg'] = change_q_x_a(antispam($form['msg']), false, false); } $yt_link = substr(change_q_x(antispam(str_replace('watch?v=', 'v/', $form['yt_link'])), true), 0, 128); if ($yt_link != '') { if (strpos($yt_link, 'http://ru.youtube.com/v/') !== 0 && strpos($yt_link, 'http://youtube.com/v/') !== 0 && strpos($yt_link, 'http://www.youtube.com/v/') !== 0) { $validate_errors['yt_link'] = 'Неверная ссылка.'; } } if (sizeof($validate_errors) > 0) { echo json_encode(array('success' => 0, 'validate' => $validate_errors)); exit(1); } $save = front::toWin(array('title' => $form['title'], 'msg' => $form['msg'], 'yt_link' => $yt_link)); $id = intval($id = front::$_req['id']); if ($id_comm) { // if($parent > 0) { // // } else { $save['id_blog'] = $parent; $save['id_reply'] = $id; $save['id_user'] = get_uid(); $id = $db->insert('corporative_blog', $save); // } //if($id_comm && $id > 0) { // $save["id_blog"] = $id; // $save["id_reply"] = $id; // } } else { if ($id > 0) { $save['id_modified'] = get_uid(); $save['id_deleted'] = 0; $save['date_change'] = date('Y-m-d H:i:s'); $aff = $db->update('UPDATE corporative_blog SET ?s WHERE (id = ?n)', $save, $id); } else { $save['id_user'] = get_uid(); $id = $db->insert('corporative_blog', $save); } } if ($form['files_deleted'] != '') { $form['files_deleted'] = preg_replace('/\\\\\\"/', '"', $form['files_deleted']); $filesBefore = json_decode($form['files_deleted']); $login = $_SESSION['login']; foreach ($filesBefore as $file) { if (!$file->db_id) { continue; } front::og('db')->delete('DELETE FROM corporative_blog_attach WHERE id = ?n', $file->db_id); } } if ($form['files'] != '') { //$filesBefore = explode(";", $form["files"]); // vardump($form["files"]); $form['files'] = preg_replace('/\\\\\\"/', '"', $form['files']); $filesBefore = json_decode($form['files']); if ($group == 7) { $max_image_size = array('width' => 400, 'height' => 600, 'less' => 0); } else { $max_image_size = array('width' => 470, 'height' => 1000, 'less' => 0); } $login = $_SESSION['login']; if ($filesBefore) { foreach ($filesBefore as $file) { if (!$file->temp) { continue; } $b_file = new CFile('temp/' . $file->id); if ($b_file->id > 0) { $b_file->Rename('users/' . substr($login, 0, 2) . '/' . $login . '/upload' . '/' . $file->id); $ext = $b_file->getext(); if (in_array($ext, $GLOBALS['graf_array'])) { $is_image = true; } else { $is_image = false; } $b_file->max_size = blogs::MAX_FILE_SIZE; $b_file->proportional = 1; if (!isNulArray($file->error)) { // $error_flag = 1; //print_r($file->error); $alert[3] = 'Один или несколько файлов не удовлетворяют условиям загрузки.'; // break; } else { if ($is_image && $ext != 'swf' && $ext != 'flv') { if (!$b_file->image_size['width'] || !$b_file->image_size['height']) { // $error_flag = 1; $alert[3] = 'Невозможно уменьшить картинку'; break; } if (!$error_flag && ($b_file->image_size['width'] > $max_image_size['width'] || $b_file->image_size['height'] > $max_image_size['height'])) { if (!$b_file->img_to_small('sm_' . $file->id, $max_image_size)) { // $error_flag = 1; $alert[3] = 'Невозможно уменьшить картинку.'; break; } else { $b_file->tn = 2; $b_file->p_name = 'sm_' . $file->id; } } else { $b_file->tn = 1; } } elseif ($ext == 'flv') { $b_file->tn = 2; } else { $b_file->tn = 0; } if ($alert[3]) { $validate_errors['files'] = $alert[3]; } $files[] = $b_file; } } } } } //global $session; if (is_array($files) && sizeof($files)) { $asql = ''; foreach ($files as $file) { //currval('corporative_blog_id_seq') if ($file->name) { $asql .= ", ({$id}, '{$file->name}', '{$file->tn}')"; } } if ($asql) { $asql = substr($asql, 2); } } //echo $asql; if ($asql) { pg_query(DBConnect(), "INSERT INTO corporative_blog_attach(msg_id, \"name\", small) VALUES {$asql}"); } $htmlMode = front::$_req['htmlMode']; if ($htmlMode == 'inPostPage') { front::og('tpl')->blog = front::og('db')->select('SELECT cb.*, u.login, u.uname, u.usurname, u.role, u.is_pro, u.is_pro_test, u.boss_rate FROM corporative_blog as cb, users as u WHERE cb.id = ? AND u.uid = cb.id_user;', $id)->fetchRow(); $attach_blog = front::og('db')->select('SELECT * FROM corporative_blog_attach WHERE msg_id = ?', $id)->fetchAll(); if ($attach_blog) { front::og('tpl')->attach_blog = $attach_blog; } // front::og("tpl")->usbank = $usr; // front::og("tpl")->comment = $comm; //front::og("tpl")->blog = $blog; $html = front::og('tpl')->fetch('my_corporative_post_item.tpl'); } elseif ($htmlMode == 'normal') { $blog = front::og('db')->select('SELECT * FROM corporative_blog WHERE id_blog = 0 AND (id_deleted IS NULL OR id_deleted = 0) AND id = ?n', $id)->fetchRow(); $bids = array($id => $id); $uids = array($blog['id_user'] => $blog['id_user']); $comm = front::get_hash(front::og('db')->select('SELECT COUNT(id_blog) as count, id_blog FROM corporative_blog WHERE id_blog IN(?a) GROUP BY id_blog', $bids)->fetchAll(), 'id_blog', 'count'); $user = front::og('db')->select('SELECT uname, usurname, login, uid, role, is_pro, is_pro_test, boss_rate FROM users WHERE uid IN(?a)', $uids)->fetchAll(); //, "uid", "usname"); $cid[$blog['id']] = $blog['id']; if ($cid) { $attach = front::og('db')->select('SELECT * FROM corporative_blog_attach WHERE msg_id IN(?a)', $cid)->fetchAll(); } if ($attach) { foreach ($attach as $key => $val) { $res_attach[$val['msg_id']][] = $val; } front::og('tpl')->attach = $res_attach; } foreach ($user as $k => $v) { $usr[$v['uid']] = $v; } front::og('tpl')->usbank = $usr; front::og('tpl')->comment = $comm; front::og('tpl')->blog = $blog; $html = front::og('tpl')->fetch('my_corporative_item.tpl'); } echo json_encode(array('success' => true, 'id' => $id, 'html' => front::toUtf($html))); }
function saveAction() { $db = front::og("db"); $form = front::$_req["form"]; $id_comm = front::$_req["comment"]; $parent = front::$_req["parent"]; if (!$id_comm) { $id_comm = false; } // global $session; $validate_errors = array(); $save = array(); if (($str = trim($form['title'])) && mb_strlen($str) >= 3) { $save['title'] = change_q_x_a(antispam($str), 0, 96); } else { $validate_errors['title'] = 'Заголовок короче 3 символов'; } if (($str = trim($form['msg'])) && mb_strlen($str) >= 3) { $save['msg'] = change_q_x_a(antispam($str), false, false); } else { $validate_errors['msg'] = 'Текст короче 3 символов'; } if (strlen($form['msg']) > blogs::MAX_DESC_CHARS) { $validate_errors['msg'] = "Максимальный размер сообщения " . blogs::MAX_DESC_CHARS . " символов!"; } else { $save['msg'] = change_q_x_a(antispam($form['msg']), false, false); } $yt_link = substr(change_q_x(antispam(str_replace('watch?v=', 'v/', $form['yt_link'])), true), 0, 128); if ($yt_link != '') { if (strpos($yt_link, 'http://ru.youtube.com/v/') !== 0 && strpos($yt_link, 'http://youtube.com/v/') !== 0 && strpos($yt_link, 'http://www.youtube.com/v/') !== 0) { $validate_errors['yt_link'] = "Неверная ссылка."; } } if (sizeof($validate_errors) > 0) { echo json_encode(array("success" => 0, "validate" => $validate_errors)); exit(1); } $save = front::toWin(array("title" => $form["title"], "msg" => $form["msg"], "yt_link" => $yt_link)); $id = intval($id = front::$_req["id"]); if ($id_comm) { // if($parent > 0) { // // } else { $save["id_blog"] = $parent; $save["id_reply"] = $id; $save["id_user"] = get_uid(); $id = $db->insert("corporative_blog", $save); // } //if($id_comm && $id > 0) { // $save["id_blog"] = $id; // $save["id_reply"] = $id; // } } else { if ($id > 0) { $save["id_modified"] = get_uid(); $save["id_deleted"] = 0; $save["date_change"] = date("Y-m-d H:i:s"); $aff = $db->update("UPDATE corporative_blog SET ?s WHERE (id = ?n)", $save, $id); } else { $save["id_user"] = get_uid(); $id = $db->insert("corporative_blog", $save); } } if ($form["files_deleted"] != "") { $form["files_deleted"] = preg_replace('/\\\\\\"/', '"', $form["files_deleted"]); $filesBefore = json_decode($form["files_deleted"]); $login = $_SESSION['login']; foreach ($filesBefore as $file) { if (!$file->db_id) { continue; } front::og("db")->delete("DELETE FROM corporative_blog_attach WHERE id = ?n", $file->db_id); } } if ($form["files"] != "") { //$filesBefore = explode(";", $form["files"]); // vardump($form["files"]); $form["files"] = preg_replace('/\\\\\\"/', '"', $form["files"]); $filesBefore = json_decode($form["files"]); if ($group == 7) { $max_image_size = array('width' => 400, 'height' => 600, 'less' => 0); } else { $max_image_size = array('width' => 470, 'height' => 1000, 'less' => 0); } $login = $_SESSION["login"]; if ($filesBefore) { foreach ($filesBefore as $file) { if (!$file->temp) { continue; } $b_file = new CFile("temp/" . $file->id); if ($b_file->id > 0) { $b_file->Rename("users/" . substr($login, 0, 2) . "/" . $login . "/upload" . "/" . $file->id); $ext = $b_file->getext(); if (in_array($ext, $GLOBALS['graf_array'])) { $is_image = TRUE; } else { $is_image = FALSE; } $b_file->max_size = blogs::MAX_FILE_SIZE; $b_file->proportional = 1; if (!isNulArray($file->error)) { // $error_flag = 1; //print_r($file->error); $alert[3] = "Один или несколько файлов не удовлетворяют условиям загрузки."; // break; } else { if ($is_image && $ext != 'swf' && $ext != 'flv') { if (!$b_file->image_size['width'] || !$b_file->image_size['height']) { // $error_flag = 1; $alert[3] = 'Невозможно уменьшить картинку'; break; } if (!$error_flag && ($b_file->image_size['width'] > $max_image_size['width'] || $b_file->image_size['height'] > $max_image_size['height'])) { if (!$b_file->img_to_small("sm_" . $file->id, $max_image_size)) { // $error_flag = 1; $alert[3] = 'Невозможно уменьшить картинку.'; break; } else { $b_file->tn = 2; $b_file->p_name = "sm_" . $file->id; } } else { $b_file->tn = 1; } } else { if ($ext == 'flv') { $b_file->tn = 2; } else { $b_file->tn = 0; } } if ($alert[3]) { $validate_errors['files'] = $alert[3]; } $files[] = $b_file; } } } } } //global $session; if (is_array($files) && sizeof($files)) { $asql = ''; foreach ($files as $file) { //currval('corporative_blog_id_seq') if ($file->name) { $asql .= ", ({$id}, '{$file->name}', '{$file->tn}')"; } } if ($asql) { $asql = substr($asql, 2); } } //echo $asql; if ($asql) { pg_query(DBConnect(), "INSERT INTO corporative_blog_attach(msg_id, \"name\", small) VALUES {$asql}"); } $htmlMode = front::$_req["htmlMode"]; if ($htmlMode == "inPostPage") { front::og("tpl")->blog = front::og("db")->select("SELECT cb.*, u.login, u.uname, u.usurname, u.role, u.is_pro, u.is_pro_test, u.boss_rate FROM corporative_blog as cb, users as u WHERE cb.id = ? AND u.uid = cb.id_user;", $id)->fetchRow(); $attach_blog = front::og("db")->select("SELECT * FROM corporative_blog_attach WHERE msg_id = ?", $id)->fetchAll(); if ($attach_blog) { front::og("tpl")->attach_blog = $attach_blog; } // front::og("tpl")->usbank = $usr; // front::og("tpl")->comment = $comm; //front::og("tpl")->blog = $blog; $html = front::og("tpl")->fetch("my_corporative_post_item.tpl"); } elseif ($htmlMode == "normal") { $blog = front::og("db")->select("SELECT * FROM corporative_blog WHERE id_blog = 0 AND (id_deleted IS NULL OR id_deleted = 0) AND id = ?n", $id)->fetchRow(); $bids = array($id => $id); $uids = array($blog["id_user"] => $blog["id_user"]); $comm = front::get_hash(front::og("db")->select("SELECT COUNT(id_blog) as count, id_blog FROM corporative_blog WHERE id_blog IN(?a) GROUP BY id_blog", $bids)->fetchAll(), "id_blog", "count"); $user = front::og("db")->select("SELECT uname, usurname, login, uid, role, is_pro, is_pro_test, boss_rate FROM users WHERE uid IN(?a)", $uids)->fetchAll(); //, "uid", "usname"); $cid[$blog['id']] = $blog['id']; if ($cid) { $attach = front::og("db")->select("SELECT * FROM corporative_blog_attach WHERE msg_id IN(?a)", $cid)->fetchAll(); } if ($attach) { foreach ($attach as $key => $val) { $res_attach[$val['msg_id']][] = $val; } front::og("tpl")->attach = $res_attach; } foreach ($user as $k => $v) { $usr[$v['uid']] = $v; } front::og("tpl")->usbank = $usr; front::og("tpl")->comment = $comm; front::og("tpl")->blog = $blog; $html = front::og("tpl")->fetch("my_corporative_item.tpl"); } echo json_encode(array("success" => true, "id" => $id, "html" => front::toUtf($html))); }