示例#1
0
        }
    }
} else {
    foreach ($templateData as $k => $i){
        $newTemplateData[$k] = $templateData[$k];
    }
}
*/
if (!($update = $saved->update_JSON($template, $templateData))) {
    Ajax::outputError('JSON file couldn\'t be updated');
}
//!copy original messages
$savedJSON = $saved->getJSONContent();
$savedData = json_decode($savedJSON, true);
$savedData['configs']['notify'] = $initialData['configs']['notify'];
$savedData['configs']['displayRulesFlag'] = $initialData['configs']['displayRulesFlag'];
$savedData['display_rules'] = $initialData['display_rules'];
//$savedData['configs']['notify']['message'] = $initialData['configs']['notify']['message'];
if (!$saved->updateJSON_Data($savedData)) {
    Ajax::outputError('JSON file couldn\'t be updated');
}
//!end
$notif = Notify::getByHash($hash);
if (!($reload = $notif->getJSONContent())) {
    Ajax::output('Can\'t reload json data!');
}
if ($xmlTemplate) {
    Ajax::output($customize->getHtml($xmlTemplate, $reload));
} else {
    Ajax::outputError('Internal server error. Try again later');
}
示例#2
0
Ajax::requireLoggedIn();
$quizHash = isset($_GET['quiz']) ? $_GET['quiz'] : null;
$quiz = Quiz::getByHash($quizHash);
if (empty($quiz->id) || !$quiz->hasAccess()) {
    Ajax::outputError('You don\'t have access to this quiz');
}
$filter = new Filter();
$saveType = 'insert';
if (isset($_GET['filter_id']) && !empty($_GET['filter_id'])) {
    $filter->readId($_GET['filter_id']);
    if (empty($filter->id)) {
        Ajax::outputError('Invalid filter');
    }
    if ($filter->quiz_id != $quiz->id) {
        Ajax::outputError('Invalid filter');
    }
    $saveType = 'update';
}
$data = new stdClass();
$data->question = isset($_GET['question']) ? $_GET['question'] : null;
$data->answer = isset($_GET['answer']) ? $_GET['answer'] : null;
if (!empty($_GET['name'])) {
    $filter->name = $_GET['name'];
}
$filter->setData($data);
$filter->quiz_id = $quiz->id;
$filter->save();
$out = new stdClass();
$out->name = $filter->name;
$out->id = $filter->id;
示例#3
0
<?php

$filterId = isset($_GET['filter']) ? intval($_GET['filter']) : null;
$filter = new Filter($filterId);
if (empty($filter->id)) {
    Ajax::outputError('Invalid report');
}
$quiz = new Quiz($filter->quiz_id);
if (!$quiz->hasAccess()) {
    Ajax::outputError('Invalid report');
}
$filter->delete();
Ajax::output($filterId);
示例#4
0
<?php

Ajax::requireLoggedIn();
$hash = isset($_POST['hash']) ? $_POST['hash'] : $_GET['hash'];
$notify = Notify::getByHash($hash);
if (empty($notify->id) || !$notify->hasAccess()) {
    Ajax::outputError('You don\'t have access to this notification!');
}
Ajax::output($notify->name);
示例#5
0
<?php

Ajax::requireLoggedIn();
$id = isset($_GET['id']) ? $_GET['id'] : null;
$color = isset($_GET['color']) ? $_GET['color'] : Quiz::DEFAULT_CUSTOMIZE_BGCOLOR;
$quiz = new Quiz($id);
$match = '/^[a-f0-9]{6}$/i';
if (!preg_match($match, $color)) {
    Ajax::outputError('Invalid color');
}
if (empty($quiz->id) || !$quiz->hasAccess()) {
    Ajax::outputError('You don\'t have access to this quiz');
}
$quiz->customize_bgcolor = $color;
$quiz->save();
示例#6
0
<?php

$notify = new Notify($_GET['id']);
if (empty($notify->id)) {
    Ajax::outputError('Invalid notification');
}
$notify->delete();
示例#7
0
文件: index.php 项目: robertpop/NS
<?php

require_once "../init.php";
session_start();
#get the page::
$page = isset($_GET['page']) ? safeFileName($_GET['page']) : null;
if (empty($page) && isset($_POST['page'])) {
    $page = safeFileName($_POST['page']);
}
$controller = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . $page . '.php';
$req = isset($_POST) ? $_POST : $_GET;
if (file_exists($controller)) {
    require_once $controller;
    Ajax::output('Success');
} else {
    Ajax::outputError('Bad Request');
}
示例#8
0
if (empty($data['email'])) {
    $data['email'] = 'anonymous';
} elseif (!valid_email($data['email'])) {
    Ajax::outputError('Please enter a valid email address.');
}
if (empty($data['comment'])) {
    Ajax::outputError('Please enter your comment.');
}
if (isset($_SESSION['time_between_albums'])) {
    if ($_SESSION['time_between_albums'] + QuizComment::TIME_BETWEEN_COMMENTS > time()) {
        Ajax::outputError('You are posting comments too quickly. Slow down.');
    }
}
$quiz = new Quiz($data['quiz_id']);
if (empty($quiz->id)) {
    Ajax::outputError('Internal error');
}
$comment = new QuizComment();
$comment->quiz_id = $data['quiz_id'];
$comment->name = $data['name'];
$comment->email = $data['email'];
$comment->website = $data['website'];
$comment->comment = $data['comment'];
$comment->ip = $_SERVER['REMOTE_ADDR'];
$comment->date = $comment->now();
if (User::isLogged()) {
    if (User::getLogged()->id == $quiz->user_id) {
        $comment->owner = 1;
    }
}
$comment->save();
示例#9
0
文件: save_xml.php 项目: robertpop/NS
<?php

Ajax::requireLoggedIn();
$request = isset($_POST) ? $_POST : $_GET;
$quizId = isset($request['quiz']) ? $request['quiz'] : null;
$quiz = new Quiz($quizId);
if (empty($quiz->id) || !$quiz->hasAccess()) {
    Ajax::outputError('You don\'t have access to this quiz');
}
if (!isset($request['data']) || empty($request['data'])) {
    Ajax::outputError('Invalid data');
}
ignore_user_abort(true);
set_time_limit(120);
parse_str($request['data'], $data);
#$quiz->customize($data);
$template = new Templates($quiz->template_id);
$xmlTemplate = gzdecode(file_get_contents($template->getXmlLink()));
if (empty($xmlTemplate)) {
    Ajax::outputError('Internal error: Cannot load template xml');
}
$customize = new Customize($quiz);
$xmlTemplate = $customize->parsePost($xmlTemplate, $data);
if ($quiz->actualizeParams($xmlTemplate)) {
    Ajax::output($quiz);
} else {
    Ajax::outputError('Internal server error: Cannot save your quiz');
}
示例#10
0
<?php

Ajax::requireLoggedIn();
$message = isset($_GET['message']) ? $_GET['message'] : '';
if (!isset($message) || empty($message)) {
    Ajax::outputError("Empty message!");
}
$hash = isset($_GET['hash']) ? $_GET['hash'] : '';
if (!isset($hash) || empty($hash)) {
    Ajax::outputError("Empty hash!");
}
$user = User::getLogged();
$notification = Notify::getByHash($hash);
$feedback = new UserFeedback();
$feedback->user_id = $user->id;
$feedback->message = $message;
$feedback->date_added = getDateMysql();
$feedback->ip = $_SERVER['REMOTE_ADDR'];
$feedback->notification_id = $notification->id;
$feedback->save();
$message = '<p>' . nl2br(str_replace('  ', ' &nbsp;', $message)) . '</p><hr/>';
$message .= '<br/><h4>User info</h4>';
$message .= '<span>Screen name: ' . $user->screenname . '</span>';
$message .= '<br/><span>User email: ' . $user->email . '</span>';
$message .= '<br/><span>Account id: ' . $user->id . '</span>';
$message .= '<br/><span>Notification ID: ' . $notification->id . '</span>';
$message .= '<br/><span>Notification hash: ' . $notification->hash . '</span>';
$message .= '<br/><span>Notification name: ' . $notification->name . '</span>';
$message .= '<br/><span>Notification parent hash: ' . $notification->parent_hash . '</span>';
$mail = new PHPMailer();
$mail->CharSet = "UTF-8";
示例#11
0
<?php

Ajax::requireLoggedIn();
$notify = new Notify($_GET['item']);
if (empty($notify->id) || !$notify->hasAccess()) {
    Ajax::outputError('You don\'t have access to this notification');
}
$notifyName = trim($_GET['name']);
if (empty($notifyName)) {
    Ajax::outputError('Notification name can\'t be empty');
}
/*if ($notifyName != $notify->name) {
      if ($notify->notificationNameExists($notifyName)){
              Ajax::outputError('Notification name already exists');
      }
  }*/
$notify->changeName($notifyName);
$out['id'] = $notify->id;
$out['name'] = $notify->name;
/*
	$out = new stdClass();
	$out->id = $notify->id;
	$out->name = $notify->name;
*/
Ajax::output($out);
示例#12
0
<?php

ignore_user_abort(true);
set_time_limit(90);
$id = isset($_GET['id']) ? $_GET['id'] : null;
$state = isset($_GET['state']) ? $_GET['state'] : null;
$notify = new Notify($id);
if (!$notify->hasAccess()) {
    Ajax::outputError('You don\'t have access to this notification');
}
if (!($json = $notify->getJSONContent())) {
    Ajax::output('Could not generate default json params!');
}
//doar pe ON se mai poate pune
$params = json_decode($json, true);
$params['configs']['state'] = 'ON';
if (!$notify->updateJSON_Data($params)) {
    Ajax::outputError('Could not update json params.');
}
//doar pe ON se mai poate pune
$notify->id = $id;
$notify->state = $state == 'ON';
$notify->save();
示例#13
0
Ajax::requireLoggedIn();
$id = isset($_GET['item']) ? $_GET['item'] : null;
$notify = new Notify($id);
if (!$notify->hasAccess()) {
    Ajax::outputError('You don\'t have access to this notification');
}
if ($notify->isPremium()) {
    //Ajax::outputMyError('This notification is premium already');
}
$premiumInfo = $config->premium['others'];
$request = new SnacktoolsRequest('remove_points');
$request->addParam('user_id', User::getLogged()->id);
$request->addParam('points', $premiumInfo['points']);
$request->addParam('description', $premiumInfo['description']);
$request->addParam('service_id', $premiumInfo['id']);
$request->addParam('item_type', $premiumInfo['itemType']);
$request->addParam('item_id', $notify->id);
$response = $request->request();
if ($response->areErrors()) {
    Ajax::outputError($response->error);
}
$notify->setFlag(Notify::FLAG_PREMIUM, true);
$notify->premium_type = $response->data['buy_type'];
$notify->activatePremium($response->data['buy_type']);
$notify->actualize('no');
$out = new stdClass();
$out->id = $notify->id;
$out->flags = $notify->flags;
$out->premium_type = $notify->premium_type;
$out->date_premium = $notify->date_premium;
Ajax::output($out);