Exemple #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');
}
Exemple #2
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);
Exemple #3
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);
Exemple #4
0
<?php

$id = isset($_GET['item']) ? $_GET['item'] : null;
$snackws = isset($_GET['snackws']) ? $_GET['snackws'] : null;
//$premium = isset($_GET['premium']) && ($_GET['premium'] != 'false') ? true : false;
$notify = new Notify($id);
if (empty($notify->id)) {
    Ajax::outputError('Invalid notification');
}
Ajax::output($notify->getEmbedBarJs($snackws));
Exemple #5
0
<?php

Ajax::requireLoggedIn();
Ajax::output(Notify::getItemsFlags($_GET['items'], User::getLogged()->id));
 public function actionAjax()
 {
     if (isset($_REQUEST['tbl'])) {
         $data = $_REQUEST;
     } else {
         $data = $_POST;
     }
     if (isset($data['debug'])) {
         dump($data);
     }
     $class = new AjaxAdmin();
     $class->data = $data;
     if (method_exists($class, $data['action'])) {
         $class->{$data}['action']();
         echo $class->output();
     } else {
         $class = new Ajax();
         $class->data = $data;
         $class->{$data}['action']();
         echo $class->output();
     }
     yii::app()->end();
 }
Exemple #7
0
<?php

$sessionId = $_GET['sessionId'];
Ajax::output(SnacktoolsUserApi::login($sessionId));
Exemple #8
0
$res['labels'][$i] = date('M. j', $i);
$statsData = SnacktoolsStatsApi::getItemStats($notify->hash, $res['date1'], $res['date2']);
$res['views'] = isset($statsData) ? $statsData['totalViews'] : 0;
$res['avg'] = round($res['views'] / $days);
$d1 = date('d', strtotime($res['date1']));
$m1 = date('m', strtotime($res['date1']));
$y1 = date('Y', strtotime($res['date1']));
$d2 = date('d', strtotime($res['date2']));
$m2 = date('m', strtotime($res['date2']));
$y2 = date('Y', strtotime($res['date2']));
while (mktime(0, 0, 0, $m1, $d1, $y1) <= mktime(0, 0, 0, $m2, $d2, $y2)) {
    $t = mktime(0, 0, 0, $m1, $d1, $y1);
    $res['chart'][$t] = 0;
    $d1++;
}
if ($statsData && isset($statsData['stats'])) {
    foreach ($statsData['stats'] as &$stat) {
        $res['chart'][strtotime($stat['date'])] = $stat['views'];
    }
}
$max = max($res['chart']);
if ($max <= 1) {
    $res['indexY'] = 2;
} else {
    if ($max <= 4) {
        $res['indexY'] = $max + 1;
    }
}
$res['maxY'] = $max;
Ajax::output($res);
Exemple #9
0
<?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');
}
Exemple #10
0
<?php

$filterId = isset($_GET['filter']) ? intval($_GET['filter']) : null;
$filter = new Filter($filterId);
if (empty($filter->id)) {
    Ajax::outputError('Invalid report');
}
Ajax::output($filter->getData());
Exemple #11
0
<?php

Ajax::requireLoggedIn();
$hash = isset($_POST['hash']) ? trim($_POST['hash']) : trim($_GET['hash']);
$notify = Notify::getByHash($hash);
if (empty($notify->id) || !$notify->hasAccess()) {
    Ajax::outputError('You don\'t have access to this notification');
}
$template = new Templates($notify->template_id);
$customize = new Customize($notify);
// template
if (!($xmlTemplate = $template->getXmlContent())) {
    Ajax::outputError('Can\'t read template xml');
}
$jsonData = null;
// notification item data
if (!($json = $notify->getJSONContent())) {
    $jsonData = $json;
}
if ($xmlTemplate) {
    if ($jsonData) {
        Ajax::output($customize->getHtml($xmlTemplate, $jsonData));
    } else {
        Ajax::output($customize->getHtml($xmlTemplate, null));
    }
} else {
    Ajax::outputError('Internal server error. Try again later');
}
Exemple #12
0
require '../include/constants.php';
require INCLUDE_PATH . '/class/varproperties.php';
require INCLUDE_PATH . '/class/ajax.php';
$ajax = new Ajax();
$ajax->requireLogin(1);
URL::decode($_GET['token']);
switch (URL::getNext()) {
    case 'microblog':
        $ajax->setFunction('microblog');
        break;
    case 'accounts':
        $ajax->setFunction('accounts');
        break;
    case 'sensoren':
        $ajax->setFunction('sensoren');
        break;
    case 'conditions':
        $ajax->setFunction('conditions');
        break;
    case 'dashboard':
        $ajax->setFunction('dashboard');
        break;
    case 'logs':
        $ajax->setFunction('logs');
        break;
    case 'connections':
        $ajax->setFunction('connections');
        break;
}
$ajax->output();
Exemple #13
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();
Exemple #14
0
<?php

Ajax::requireLoggedIn();
$hash = isset($_POST['hash']) ? trim($_POST['hash']) : trim($_GET['hash']);
$field = isset($_POST['field']) ? trim($_POST['field']) : trim($_GET['field']);
$value = isset($_POST['value']) ? trim($_POST['value']) : trim($_GET['value']);
$notify = Notify::getByHash($hash);
if (empty($notify->id) || !$notify->hasAccess()) {
    Ajax::outputError('You don\'t have access to this notification');
}
$content = json_decode($notify->getJSONContent(), true);
$content['configs']['params'][$field] = $value;
$notifyJSON = $notify->updateJSON_Data($content);
if ($notifyJSON) {
    Ajax::output($notifyJSON);
} else {
    Ajax::outputError('Internal server error. Try again later');
}
Exemple #15
0
<?php

SnacktoolsUserApi::logout();
Ajax::output('Success');
Exemple #16
0
<?php

Ajax::requireLoggedIn();
$id = isset($_GET['id']) ? $_GET['id'] : null;
$quiz = new Quiz($id);
if (empty($quiz->id) || !$quiz->hasAccess()) {
    Ajax::outputError('You don\'t have access to this quiz');
}
$newQuiz = $quiz->duplicate();
$newQuiz->dateFormated = date("F j, Y", strtotime($newQuiz->date_created));
$newQuiz->name_short = $newQuiz->getShortName(45);
Ajax::output($newQuiz);
Exemple #17
0
$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;
$out->saveType = $saveType;
Ajax::output($out);
Exemple #18
0
<?php

$smarty = Application::getSmarty('ajax/templates', 'ajax/templates_c');
$width = isset($_GET['width']) ? $_GET['width'] : 0;
$height = isset($_GET['height']) ? $_GET['height'] : 0;
$sizes = QuizSize::getAllSizes();
$maxSize = QuizSize::getMax($sizes);
$smarty->assign('sizes', $sizes);
$smarty->assign('width', $width);
$smarty->assign('height', $height);
$smarty->assign('widgetMaxWidth', Settings::getValueByName('widget_max_width'));
$smarty->assign('widgetMinWidth', Settings::getValueByName('widget_min_width'));
$smarty->assign('widgetMaxHeight', Settings::getValueByName('widget_max_height'));
$smarty->assign('widgetMinHeight', Settings::getValueByName('widget_min_height'));
Ajax::output($smarty->fetch('get_sizes.tpl'));