Пример #1
0
 public function Image($id)
 {
     $upload = new TUpload();
     $result = $upload->Save('image');
     $url = str_replace('../upload/', UR_UPLOAD, $result['value']['path']);
     $this->model->Edit($id, array('topic_image' => $url));
     GoBack();
 }
Пример #2
0
 public function Update($id)
 {
     if (isset($_POST['ajax'])) {
         unset($_POST['ajax']);
         $result['success'] = $this->model->Edit($id, array('widget_setting' => serialize($_POST)));
         $result['value'] = null;
         echo json_encode($result);
     } else {
         $this->model->Edit($id, array('widget_setting' => serialize($_POST)));
         GoBack();
     }
 }
Пример #3
0
 public function Upload()
 {
     if (file_exists($_FILES['file']['tmp_name'])) {
         $zip = new TCompress();
         //        print_r();
         $zip->ZipExtract(PLUGIN_DIR, $_FILES['file']['tmp_name']);
         unlink($_FILES['file']['tmp_name']);
     }
     GoBack();
 }
function IndexPollsVoice()
{
    if (!isset($_GET['poll_id'])) {
        GoBack();
    }
    if (!isset($_POST['voice'])) {
        System::site()->AddTextBox('', '<p align="center">Вы не выбрали ни одного варианта ответа.</p>');
    } else {
        $pid = SafeEnv($_GET['poll_id'], 11, int);
        System::database()->Select('polls', GetWhereByAccess('view', "`id`='{$pid}' and `active`='1'"));
        if (System::database()->NumRows() == 0) {
            GoBack();
        }
        $poll = System::database()->FetchRow();
        $answers = unserialize($poll['answers']);
        $multianswers = SafeDB($poll['multianswers'], 1, int);
        $voice = SafeEnv($_POST['voice'], 11, int);
        if (!$multianswers) {
            $voice = $voice[0];
        }
        //Проверяем, учавствовал ли данный пользователь в этом опросе
        $ip = getip();
        if (System::user()->Auth) {
            $uid = System::user()->Get('u_id');
        } else {
            $uid = -1;
        }
        System::database()->Select('polls_voices', "`poll_id`='{$pid}' and (`user_ip`='{$ip}' or `user_id`='{$uid}')");
        if (System::database()->NumRows() == 0) {
            if (!$multianswers) {
                if (isset($answers[$voice])) {
                    $answers[$voice][2] = $answers[$voice][2] + 1;
                    $answers = serialize($answers);
                    System::database()->Update('polls', "answers='{$answers}'", "`id`='{$pid}'");
                } else {
                    GoBack();
                }
            } else {
                $c = count($voice);
                for ($i = 0; $i < $c; $i++) {
                    if (isset($answers[$voice[$i]])) {
                        $answers[$voice[$i]][2] = $answers[$voice[$i]][2] + 1;
                    } else {
                        GoBack();
                    }
                }
                $answers = serialize($answers);
                System::database()->Update('polls', "answers='{$answers}'", "`id`='{$pid}'");
            }
            $voice = serialize($voice);
            if (System::user()->Auth) {
                $user_id = System::user()->Get('u_id');
            } else {
                $user_id = 0;
            }
            System::database()->Insert('polls_voices', "'','{$pid}','" . getip() . "','{$voice}','{$user_id}'");
            System::user()->ChargePoints(System::config('points/polls_answer'));
            GoBack();
        } else {
            System::site()->AddTextBox('', '<p align="center">Извините, Вы уже принимали участие в этом опросе.</p>');
        }
    }
}
Пример #5
0
 /**
  * universak bulk action in controller
  * @return string
  */
 public function BulkAction()
 {
     $arr = explode(',', $_POST['action']);
     switch ($arr[0]) {
         case 'Delete':
             foreach ($_POST['id'] as $id) {
                 $this->model->Delete($id);
             }
             break;
         case 'Edit':
             $data = array($arr[1] => $arr[2]);
             foreach ($_POST['id'] as $id) {
                 $this->model->Edit($id, $data);
             }
             break;
         default:
             return 'error';
             break;
     }
     GoBack('/do');
 }
Пример #6
0
 public function Delete($id)
 {
     $this->model->Delete(intval($id));
     GoBack();
 }
Пример #7
0
 public function SaveSetting()
 {
     $this->model->SaveSetting();
     GoBack();
 }
function IndexUserLogOut()
{
    if (System::user()->Auth) {
        System::user()->UnLogin(false);
        GoBack();
    } else {
        System::site()->Login();
        // Если не авторизирован, то показываем форму входа
    }
}
Пример #9
0
                echo json_encode($result);
                die;
            }
        }
        $result['success'] = false;
        $result['value'] = 'اعتبار حساب کاربری شما برای لایک خدشه دار است.';
        echo json_encode($result);
        break;
    case 'comment':
        if (isset($_COOKIE['mid'])) {
            $valid = array('comment_parent', 'comment_text', 'comment_topic_id');
            $edit = promis($clean, $valid);
            $m = new TModel('comment', 'comment_');
            $data = array('comment_parent' => $clean['comment_parent'], 'comment_text' => $clean['comment_text'], 'comment_topic_id' => $clean['comment_topic_id'], 'comment_member_id' => $_COOKIE['mid'], 'comment_time' => time(), 'comment_ip' => _ipi());
            $tmp = $m->Create($data);
            if (isset($clean['ajax'])) {
                $result['success'] = $tmp != false ? true : false;
                echo json_encode($result);
                die;
            } else {
                GoBack();
            }
        } else {
            $result['value'] = 'شما بایستی وارده شده باشید';
            echo json_encode($result);
            die;
        }
        break;
    default:
        break;
}
Пример #10
0
 public function RemoveReport($id)
 {
     $this->report->Delete($id);
     GoBack();
 }
Пример #11
0
 public function Save($setting)
 {
     //        error_reporting(0);
     $reg = TRegistry::GetInstance();
     if ($reg->GetValue(ROOT_SYSTEM, $setting) === FALSE) {
         $reg->AddValue(ROOT_SYSTEM, $setting, serialize($_POST[$setting]));
     } else {
         $reg->SetValue(ROOT_SYSTEM, $setting, serialize($_POST[$setting]));
     }
     //echo serialize($_POST[$setting]);
     if (is_array($_FILES)) {
         foreach ($_FILES as $key => $value) {
             $fname = str_replace('__', '.', $key);
             move_uploaded_file($_FILES[$key]['tmp_name'], '../assets/images/' . $fname);
         }
     }
     GoBack();
 }
Пример #12
0
 public function RemoveAttach($attach_id, $destination, $type = REALTION_ATTACH)
 {
     $rel = TRelation::GetInstance();
     $rel->Remove($attach_id, $destination, $type);
     GoBack();
 }
function IndexForumRestoreBasketTopic($topic_id = 0, $go_back = true)
{
    global $forum_lang;
    if (!System::user()->isAdmin()) {
        HackOff();
        return;
    }
    $topic = System::database()->Select('forum_topics', "`id`='{$topic_id}' and `delete`='1'");
    if (count($topic) > 0) {
        $topic = $topic[0];
        $forum_id = SafeEnv($topic['forum_id'], 11, int);
        // Восстанавливаем количество сообщений и тем для форума
        System::database()->Select('forums', "`id`='{$forum_id}'");
        if (System::database()->NumRows() == 0) {
            // Форум не найден
            System::site()->AddTextBox($forum_lang['error'], $forum_lang['error_no_forum']);
            return;
        }
        $forum = System::database()->FetchRow();
        $forum_topics = SafeEnv($forum['topics'], 11, int) + 1;
        if ($forum_topics < 0) {
            $forum_topics = 0;
        }
        $forum_posts = SafeEnv($forum['posts'], 11, int) + SafeEnv($topic['posts'], 11, int);
        if ($forum_posts < 0) {
            $forum_posts = 0;
        }
        $forum_set = "`topics`='{$forum_topics}',`posts`='{$forum_posts}'";
        System::database()->Update('forums', $forum_set, "`id`='{$forum_id}'");
        // Восстанавливаем тему
        System::database()->Update('forum_topics', "`delete`='0'", "`id`='{$topic_id}'");
        // Удаляем метку в корзине
        System::database()->Delete('forum_basket_topics', "`obj_id`='{$topic_id}'");
        // Устанавливаем инф-ю о последнем сообщении для темы и форума
        ForumSetLastPost($topic_id);
        ForumSetLastTopic($forum_id);
        // Очищаем кэш форума
        ForumCacheClear();
        if ($go_back) {
            if (isset($_GET['back'])) {
                GoRefererUrl($_GET['back']);
            } else {
                GoBack();
            }
        }
    } else {
        System::site()->AddTextBox($forum_lang['error'], $forum_lang['error_no_topic']);
        return;
    }
}