예제 #1
0
 /**
  * Parse feeds into an array, ready to pass to the Javascript importer
  *
  * @param string $opml_url URL to parse feed data from, in the OPML standard.
  * @return array Associative array containing feed URL, title and category (if applicable)
  */
 protected function import_opml($opml_url)
 {
     if (empty($opml_url)) {
         MessageHandler::add_error(sprintf(_r('No OPML specified')));
         return false;
     }
     require_once LILINA_INCPATH . '/contrib/simplepie/simplepie.inc';
     $opml = new SimplePie_File($opml_url);
     $opml = new OPML($opml->body);
     if (!empty($opml->error) || empty($opml->data)) {
         MessageHandler::add_error(sprintf(_r('The OPML file could not be read. The parser said: %s'), $opml->error));
         return false;
     }
     $feeds_num = 0;
     foreach ($opml->data as $cat => $feed) {
         if (!isset($feed['xmlurl']) && isset($feed[0]['xmlurl'])) {
             foreach ($feed as $subfeed) {
                 $feeds[] = array('url' => $subfeed['xmlurl'], 'title' => $subfeed['title'], 'cat' => $cat);
                 ++$feeds_num;
             }
             continue;
         }
         $feeds[] = array('url' => $feed['xmlurl'], 'title' => $feed['title'], 'cat' => '');
         ++$feeds_num;
     }
     MessageHandler::add(sprintf(__ngettext('Adding %d feed', 'Adding %d feeds', $feeds_num), $feeds_num));
     return $feeds;
 }
예제 #2
0
 public static function getLatestMessages($user_id, $chat_id, $from_beginning)
 {
     require_once "handlers/MessageHandler.php";
     $data = MessageHandler::getLatestMessages($user_id, $chat_id, $from_beginning);
     static::updateChatActivity($user_id, $chat_id);
     return $data;
 }
예제 #3
0
 public static function error($message, $template = null)
 {
     if (!is_null($template)) {
         parent::$template = $template;
     }
     parent::loadMessage($message);
 }
예제 #4
0
파일: Worlds.php 프로젝트: Roj/BFERev
 public function Enter()
 {
     global $Template, $Database, $BaseURL;
     $Arguments = func_get_args();
     if (count($Arguments) > 1) {
         MessageHandler::HandleUserError("Argument not specified.");
         return;
     }
     $WorldID = intval($Arguments[0]);
     $WorldQuery = "SELECT * FROM worlds WHERE WorldID = '{$WorldID}'";
     $WorldQuery = $Database->Query($WorldQuery);
     if (mysql_num_rows($WorldQuery) < 1) {
         MessageHandler::HandleUserError("The world you requested to enter does not exist!");
         return;
     }
     if ($World = mysql_fetch_array($WorldQuery)) {
         if ($World['MinLevel'] > $_SESSION['CharacterInfo']['Level']) {
             MessageHandler::HandleUserError("Your level is not suitable for this world. Dangerous monsters lie there.");
             return;
         }
         $_SESSION['CurrentWorld'] = $World['WorldID'];
         header("Location: {$BaseURL}/index.php/Worlds/View/{$World['WorldID']}");
         return;
     }
 }
예제 #5
0
 /**
  *
  * @return MessageHandler
  */
 public static function instance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #6
0
 /**
  * Parse feeds into an array, ready to pass to the Javascript importer
  *
  * @param string $opml OPML standard file.
  * @return array Associative array containing feed URL, title and category (if applicable)
  */
 protected function import_opml($opml)
 {
     if (empty($opml)) {
         throw new Exception(_r('No OPML specified'));
         return false;
     }
     $opml = new OPMLParser($opml);
     if (!empty($opml->error) || empty($opml->data)) {
         throw new Exception(sprintf(_r('The OPML file could not be read. The parser said: %s'), $opml->error));
         return false;
     }
     $feeds_num = 0;
     foreach ($opml->data as $cat => $feed) {
         if (!isset($feed['xmlurl']) && isset($feed[0]['xmlurl'])) {
             foreach ($feed as $subfeed) {
                 $feeds[] = array('url' => $subfeed['xmlurl'], 'title' => $subfeed['title'], 'cat' => $cat);
                 ++$feeds_num;
             }
             continue;
         }
         $feeds[] = array('url' => $feed['xmlurl'], 'title' => $feed['title'], 'cat' => '');
         ++$feeds_num;
     }
     MessageHandler::add(sprintf(Locale::ngettext('Adding %d feed', 'Adding %d feeds', $feeds_num), $feeds_num));
     return $feeds;
 }
예제 #7
0
 /**
  * function instance
  *
  * @param string $dsn - a valid data source name
  * @return MessageHandler instance
  */
 public static function instance($dsn = NULL)
 {
     if (self::$instance == NULL) {
         self::$instance = new MessageHandler($dsn);
     } else {
         self::$instance->setDSN($dsn);
     }
     return self::$instance;
 }
 public function delete()
 {
     if (ProjectService::delete(Request::get('id'))) {
         MessageHandler::instance()->addMessage('Deleted project');
         $this->asJson(true);
     } else {
         MessageHandler::instance()->addError('Could not delete project');
         $this->asJson(false);
     }
 }
예제 #9
0
	public static function addMessage($message){
		$sys = MessageHandler::getInstance();
		if (isset($sys->messageList))
			$sys->lastMessage->addMessage ($message );
		else 
			$sys->messageList = $message;
		
		$sys->lastMessage = $message;
		if($message->getType()=="ERROR")
			exit;
	}
예제 #10
0
 public function register()
 {
     $this->validate(array('name' => 'required,min(2)', 'email' => 'required,email', 'password' => 'required,min(4)', 'password2' => 'required,min(4),equal(password)'));
     $userDoc = Request::post()->get('name', 'email', 'password');
     $userDoc->password = md5($userDoc->password);
     $userDoc = UserService::save($userDoc);
     if (!$userDoc) {
         MessageHandler::instance()->addError('E-mail was already registered - forgot your password?');
         return;
     }
     $user = new UserModel($userDoc);
     SessionHandler::instance()->setUser($user);
     MessageHandler::instance()->addMessage('You were successfully registered and logged in');
     $this->redirect();
 }
예제 #11
0
 /**
  * Parse feeds into an array, ready to pass to the Javascript importer
  *
  * @param string $opml OPML standard file.
  * @return array Associative array containing feed URL, title and category (if applicable)
  */
 protected function import_opml($opml)
 {
     if (empty($opml)) {
         throw new Exception(_r('No OPML specified'));
         return false;
     }
     $opml = new OPMLParser($opml);
     if (!empty($opml->error) || empty($opml->data)) {
         throw new Exception(sprintf(_r('The OPML file could not be read. The parser said: %s'), $opml->error));
         return false;
     }
     $feeds_num = 0;
     $feeds = $this->parse($opml->data);
     MessageHandler::add(sprintf(Locale::ngettext('Adding %d feed', 'Adding %d feeds', $feeds_num), $feeds_num));
     return $feeds;
 }
예제 #12
0
파일: Register.php 프로젝트: Roj/BFERev
 public function _do()
 {
     global $Database, $Template;
     $Template->set_filenames(array('register' => 'templates/register.html', 'register_successfull' => 'templates/regsuccess.html'));
     $Username = mysql_real_escape_string($_POST['username']);
     $Password = md5($_POST['password']);
     $Mail = mysql_real_escape_string($_POST['email']);
     $IP = $_SERVER['REMOTE_ADDR'];
     if (mysql_num_rows($Database->Query("SELECT username FROM users WHERE username='******'")) > 0) {
         MessageHandler::HandleUserError("Sorry, but it appears that your username is already in use! " . $Database->LastQueryString);
         $Template->assign_block_vars('predef', array('username' => $Username, 'password' => $_POST['password'], 'email' => $Mail));
         $this->Handle = "register";
         return;
     }
     if ($Mail != filter_var($Mail, FILTER_VALIDATE_EMAIL)) {
         MessageHandler::HandleUserError("I couldn't recognize your email. Perhaps you made a typo?");
         $this->Handle = "register";
         return;
     }
     $Database->Query("INSERT INTO users(username,password,email,ip,registered,rank) VALUES('{$Username}','{$Password}','{$Mail}','{$IP}',CURRENT_TIMESTAMP,1)");
     $Template->assign_var("username", $Username);
     $this->Handle = 'register_successfull';
 }
예제 #13
0
파일: Login.php 프로젝트: Roj/BFERev
 public function _do()
 {
     global $Database, $Template;
     if (empty($_POST['username']) || empty($_POST['password'])) {
         MessageHandler::HandleUserError("Hmmm, mind checking if you filled all fields?");
         $this->Handle = 'login';
         return;
     }
     $Username = mysql_real_escape_string($_POST['username']);
     $Password = mysql_real_escape_string($_POST['password']);
     $Query = $Database->Query("SELECT * FROM users WHERE username = '******'");
     if (mysql_num_rows($Query) > 0 && ($Row = mysql_fetch_array($Query))) {
         if ($Row['username'] == $Username && md5($Password) == $Row['password']) {
             $_SESSION['USERINFO'] = $Row;
             header("Location: " . BaseURL . "index.php");
             return;
         } else {
             MessageHandler::HandleUserError("Sorry, but it appears that the password is incorrect");
         }
     } else {
         MessageHandler::HandleUserError("I was unable to find a user named like that. Mind checking it?");
     }
     $this->Handle = 'login';
 }
예제 #14
0
             if (AMA_DataHandler::isError($tutor_id)) {
                 //?
             }
             // only one tutor per class
             if ($tutor_id) {
                 $tutor = $dh->get_tutor($tutor_id);
                 if (!AMA_DataHandler::isError($tutor)) {
                     // prepare message to send
                     $message_ha['destinatari'] = $tutor['username'];
                     $message_ha['titolo'] = translateFN("Esercizio svolto da ") . $user_name . "<br>";
                     $message_ha['testo'] = $correttore->getMessageForTutor($user_name, $exercise);
                     $message_ha['data_ora'] = "now";
                     $message_ha['tipo'] = ADA_MSG_SIMPLE;
                     $message_ha['priorita'] = 1;
                     $message_ha['mittente'] = $user_name;
                     $mh = new MessageHandler();
                     $mh->send_message($message_ha);
                 }
             }
         }
         // max level attained
     }
 }
 // genera il messaggio per lo studente
 // $dataHa['exercise'] = $correttore->getMessageForStudent($user_name, $exercise);
 $message = $correttore->getMessageForStudent($user_name, $exercise);
 $dataHa['exercise'] = $message->getHtml();
 // ottiene il prossimo esercizio da svolgere, se previsto.
 $next_exercise_id = ExerciseDAO::getNextExerciseId($exercise, $sess_id_user);
 if (AMA_DataHandler::isError($next_exercise_id)) {
     $errObj = new ADA_Error($next_exercise_id, translateFN('Errore nel caricamento del prossimo esercizio'));
예제 #15
0
/**
 * Common administration helpers
 *
 * @author Ryan McCue <*****@*****.**>
 * @package Lilina
 * @version 1.0
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
function admin_header($title, $parent_file = false)
{
    $self = preg_replace('|^.*/admin/|i', '', $_SERVER['PHP_SELF']);
    $self = preg_replace('|^.*/plugins/|i', '', $self);
    header('Content-Type: text/html; charset=utf-8');
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php 
    echo $title;
    ?>
 &mdash; <?php 
    echo get_option('sitename');
    ?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php 
    echo get_option('baseurl');
    ?>
admin/resources/jquery-ui.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="<?php 
    echo get_option('baseurl');
    ?>
admin/resources/core.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="<?php 
    echo get_option('baseurl');
    ?>
admin/resources/full.css" media="screen"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/jquery.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/json2.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/jquery.ui.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/jquery.scrollTo.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
admin/admin.js"></script>
<script type="text/javascript">
	admin.localisations = {
		"No feed URL supplied": "<?php 
    _e('No feed URL supplied');
    ?>
",
		"No feed ID supplied": "<?php 
    _e('No feed ID supplied');
    ?>
",
		"Failed to parse response: ": "<?php 
    _e('Failed to parse response: ');
    ?>
",
		"Are You Sure?": "<?php 
    _e('Are You Sure?');
    ?>
",
		"Whoops!": "<?php 
    _e('Whoops!');
    ?>
",
		"OK": "<?php 
    _e('OK');
    ?>
",
		"Cancel": "<?php 
    _e('Cancel');
    ?>
",
		"Something Went Wrong!": "<?php 
    _e('Something Went Wrong!');
    ?>
",
		"Error message:": "<?php 
    _e('Error message:');
    ?>
",
		'If you think you shouldn\'t have received this error then <a href="http://code.google.com/p/lilina/issues">report a bug</a> quoting that message and how it happened.': '<?php 
    echo str_replace("'", '\\\'', _r('If you think you shouldn\'t have received this error then <a href="http://code.google.com/p/lilina/issues">report a bug</a> quoting that message and how it happened.'));
    ?>
',
		"Double-click to edit": "<?php 
    _e('Double-click to edit');
    ?>
",
		"Delete": "<?php 
    _e('Delete');
    ?>
",
		"Show advanced options": "<?php 
    _e('Show advanced options');
    ?>
"
	};
</script>
</head>
<body id="admin-<?php 
    echo basename($self, '.php');
    ?>
" class="admin-page">
<div id="header">
	<p id="sitetitle"><a href="<?php 
    echo get_option('baseurl');
    ?>
"><?php 
    echo get_option('sitename');
    ?>
</a></p>
	<ul id="navigation">
<?php 
    $navigation = array(array(_r('Dashboard'), 'index.php', ''), array(_r('Feeds'), 'feeds.php', 'feeds'), array(_r('Settings'), 'settings.php', 'settings'));
    $navigation = apply_filters('navigation', $navigation);
    $subnavigation = apply_filters('subnavigation', array('index.php' => array(array(_r('Home'), 'index.php', 'home')), 'feeds.php' => array(array(_r('Add/Manage'), 'feeds.php', 'feeds'), array(_r('Import'), 'feed-import.php', 'feeds')), 'settings.php' => array(array(_r('General'), 'settings.php', 'settings'))), $navigation, $self);
    foreach ($navigation as $nav_item) {
        $class = 'item';
        if (strcmp($self, $nav_item[1]) == 0 || $parent_file && $nav_item[1] == $parent_file) {
            $class .= ' current';
        }
        if (isset($subnavigation[$nav_item[1]]) && count($subnavigation[$nav_item[1]]) > 1) {
            $class .= ' has-submenu';
        }
        echo "<li class='{$class}'><a href='{$nav_item[1]}'>{$nav_item[0]}</a>";
        if (!isset($subnavigation[$nav_item[1]]) || count($subnavigation[$nav_item[1]]) < 2) {
            echo "</li>";
            continue;
        }
        echo '<ul class="submenu">';
        foreach ($subnavigation[$nav_item[1]] as $subnav_item) {
            echo '<li' . (strcmp($self, $subnav_item[1]) == 0 ? ' class="current"' : '') . "><a href='{$subnav_item[1]}'>{$subnav_item[0]}</a></li>";
        }
        echo '</ul></li>';
    }
    ?>
	</ul>
	<ul id="utilities">
		<li><a href="page_item_logout"><a href="login.php?logout" title="<?php 
    _e('Log out of your current session');
    ?>
"><?php 
    _e('Sign out');
    ?>
</a></a></li>
		<?php 
    do_action('admin_utilities_items');
    ?>
	</ul>
</div>
<div id="main">
<?php 
    if ($result = implode('</p><p>', MessageHandler::get())) {
        echo '<div id="alert" class="fade"><p>' . $result . '</p></div>';
    }
    do_action('admin_header');
    do_action("admin_header-{$self}");
    do_action('send_headers');
}
예제 #16
0
 public function Enter()
 {
     global $Database, $Template, $Character;
     LoggedInOnlyFeature();
     if (func_num_args() < 1) {
         trigger_error("Invalid URL");
         return;
     }
     $CharacterID = intval(func_get_arg(0));
     if ($CharacterID == 0) {
         trigger_error("Invalid URL");
         $this->Render();
         return;
     }
     $CharacterQuery = $Database->Query("SELECT * FROM characters WHERE CharacterID='{$CharacterID}'");
     if (mysql_num_rows($CharacterQuery) < 1) {
         MessageHandler::HandleUserError('Character does not exist');
         $this->Render();
         return;
     }
     if ($Row = mysql_fetch_array($CharacterQuery)) {
         $_SESSION['CharacterInfo'] = $Row;
         header("Location: " . BaseURL);
     } else {
         trigger_error("WTF");
     }
 }
예제 #17
0
     echo $user_chat_report;
     //              header ("Connection: close");
     exit;
     break;
 case 'exportTable':
     // XLS-like
     $chat_report = "";
     if (!isset($id_chatroom)) {
         // ???
         if (isset($id_instance)) {
             $id_chatroom = $id_instance;
         } elseif (isset($sess_id_course_instance)) {
             $id_chatroom = $sess_id_course_instance;
         }
     }
     $mh = MessageHandler::instance($_SESSION['sess_selected_tester_dsn']);
     $chat_data = $mh->find_chat_messages($sess_user_id, ADA_MSG_CHAT, $id_chatroom, $fields_list = "", $clause = "", $ordering = "");
     if (is_array($chat_data)) {
         $chat_dataAr = array();
         $c = 0;
         $tbody_data = array();
         $export_log = translateFN('Data e ora') . ';' . translateFN('Utente') . ';' . translateFN('Messaggio') . PHP_EOL;
         foreach ($chat_data as $chat_msgAr) {
             if (is_numeric($chat_msgAr[0])) {
                 $sender_dataHa = $dh->_get_user_info($chat_msgAr[0]);
                 $user = $sender_dataHa['nome'] . ' ' . $sender_dataHa['cognome'];
                 $message = $chat_msgAr[1];
                 $data_ora = ts2dFN($chat_msgAr[2]) . " " . ts2tmFN($chat_msgAr[2]);
                 /*
                 *
                                             $row = array(
예제 #18
0
 public function Process()
 {
     if ($this->node->getChild("query") != null) {
         if (isset($this->parent->getNodeId()['privacy']) && $this->parent->getNodeId()['privacy'] == $this->node->getAttribute('id')) {
             $listChild = $this->node->getChild(0)->getChild(0);
             foreach ($listChild->getChildren() as $child) {
                 $blockedJids[] = $child->getAttribute('value');
             }
             $this->parent->eventManager()->fire("onGetPrivacyBlockedList", array($this->phoneNumber, $blockedJids));
             return;
         }
     }
     if ($this->node->getAttribute('type') == "get" && $this->node->getAttribute('xmlns') == "urn:xmpp:ping") {
         $this->parent->eventManager()->fire("onPing", array($this->phoneNumber, $this->node->getAttribute('id')));
         $this->parent->sendPong($this->node->getAttribute('id'));
     }
     if ($this->node->getChild("sync") != null) {
         //sync result
         $sync = $this->node->getChild('sync');
         $existing = $sync->getChild("in");
         $nonexisting = $sync->getChild("out");
         //process existing first
         $existingUsers = array();
         if (!empty($existing)) {
             foreach ($existing->getChildren() as $child) {
                 $existingUsers[$child->getData()] = $child->getAttribute("jid");
             }
         }
         //now process failed numbers
         $failedNumbers = array();
         if (!empty($nonexisting)) {
             foreach ($nonexisting->getChildren() as $child) {
                 $failedNumbers[] = str_replace('+', '', $child->getData());
             }
         }
         $index = $sync->getAttribute("index");
         $result = new SyncResult($index, $sync->getAttribute("sid"), $existingUsers, $failedNumbers);
         $this->parent->eventManager()->fire("onGetSyncResult", array($result));
     }
     if ($this->node->getChild("props") != null) {
         //server properties
         $props = array();
         foreach ($this->node->getChild(0)->getChildren() as $child) {
             $props[$child->getAttribute("name")] = $child->getAttribute("value");
         }
         $this->parent->eventManager()->fire("onGetServerProperties", array($this->phoneNumber, $this->node->getChild(0)->getAttribute("version"), $props));
     }
     if ($this->node->getChild("picture") != null) {
         $this->parent->eventManager()->fire("onGetProfilePicture", array($this->phoneNumber, $this->node->getAttribute("from"), $this->node->getChild("picture")->getAttribute("type"), $this->node->getChild("picture")->getData()));
     }
     if ($this->node->getChild("media") != null || $this->node->getChild("duplicate") != null) {
         $this->parent->processUploadResponse($this->node);
     }
     if (strpos($this->node->getAttribute("from"), Constants::WHATSAPP_GROUP_SERVER) !== false) {
         //There are multiple types of Group reponses. Also a valid group response can have NO children.
         //Events fired depend on text in the ID field.
         $groupList = array();
         $groupNodes = array();
         if ($this->node->getChild(0) != null && $this->node->getChild(0)->getChildren() != null) {
             foreach ($this->node->getChild(0)->getChildren() as $child) {
                 $groupList[] = $child->getAttributes();
                 $groupNodes[] = $child;
             }
         }
         if (isset($this->parent->getNodeId()['groupcreate']) && $this->parent->getNodeId()['groupcreate'] == $this->node->getAttribute('id')) {
             $this->parent->setGroupId($this->node->getChild(0)->getAttribute('id'));
             $this->parent->eventManager()->fire("onGroupsChatCreate", array($this->phoneNumber, $this->node->getChild(0)->getAttribute('id')));
         }
         if (isset($this->parent->getNodeId()['leavegroup']) && $this->parent->getNodeId()['leavegroup'] == $this->node->getAttribute('id')) {
             $this->parent->setGroupId($this->node->getChild(0)->getChild(0)->getAttribute('id'));
             $this->parent->eventManager()->fire("onGroupsChatEnd", array($this->phoneNumber, $this->node->getChild(0)->getChild(0)->getAttribute('id')));
         }
         if (isset($this->parent->getNodeId()['getgroups']) && $this->parent->getNodeId()['getgroups'] == $this->node->getAttribute('id')) {
             $this->parent->eventManager()->fire("onGetGroups", array($this->phoneNumber, $groupList));
             //getGroups returns a array of nodes which are exactly the same as from getGroupV2Info
             //so lets call this event, we have all data at hand, no need to call getGroupV2Info for every
             //group we are interested
             foreach ($groupNodes as $groupNode) {
                 $this->handleGroupV2InfoResponse($groupNode, true);
             }
         }
         if (isset($this->parent->getNodeId()['get_groupv2_info']) && $this->parent->getNodeId()['get_groupv2_info'] == $this->node->getAttribute('id')) {
             $groupChild = $this->node->getChild(0);
             if ($groupChild != null) {
                 $this->handleGroupV2InfoResponse($groupChild);
             }
         }
     }
     if (isset($this->parent->getNodeId()['get_lists']) && $this->parent->getNodeId()['get_lists'] == $this->node->getAttribute('id')) {
         $broadcastLists = array();
         if ($this->node->getChild(0) != null) {
             $childArray = $this->node->getChildren();
             foreach ($childArray as $list) {
                 if ($list->getChildren() != null) {
                     foreach ($list->getChildren() as $sublist) {
                         $id = $sublist->getAttribute("id");
                         $name = $sublist->getAttribute("name");
                         $broadcastLists[$id]['name'] = $name;
                         $recipients = array();
                         foreach ($sublist->getChildren() as $recipient) {
                             array_push($recipients, $recipient->getAttribute('jid'));
                         }
                         $broadcastLists[$id]['recipients'] = $recipients;
                     }
                 }
             }
         }
         $this->parent->eventManager()->fire("onGetBroadcastLists", array($this->phoneNumber, $broadcastLists));
     }
     if ($this->node->getChild("pricing") != null) {
         $this->parent->eventManager()->fire("onGetServicePricing", array($this->phoneNumber, $this->node->getChild(0)->getAttribute("price"), $this->node->getChild(0)->getAttribute("cost"), $this->node->getChild(0)->getAttribute("currency"), $this->node->getChild(0)->getAttribute("expiration")));
     }
     if ($this->node->getChild("extend") != null) {
         $this->parent->eventManager()->fire("onGetExtendAccount", array($this->phoneNumber, $this->node->getChild("account")->getAttribute("kind"), $this->node->getChild("account")->getAttribute("status"), $this->node->getChild("account")->getAttribute("creation"), $this->node->getChild("account")->getAttribute("expiration")));
     }
     if ($this->node->getChild("normalize") != null) {
         $this->parent->eventManager()->fire("onGetNormalizedJid", array($this->phoneNumber, $this->node->getChild(0)->getAttribute("result")));
     }
     if ($this->node->getChild("status") != null) {
         $child = $this->node->getChild("status");
         $childs = $child->getChildren();
         if (isset($childs) && !is_null($childs)) {
             foreach ($childs as $status) {
                 $this->parent->eventManager()->fire("onGetStatus", array($this->phoneNumber, $status->getAttribute("jid"), "requested", $this->node->getAttribute("id"), $status->getAttribute("t"), $status->getData()));
             }
         }
     }
     if ($this->node->getAttribute('type') == "error" && $this->node->getChild("error") != null) {
         $errorType = null;
         $this->parent->logFile('error', 'Iq error with {id} id', array('id' => $this->node->getAttribute('id')));
         foreach ($this->parent->getNodeId() as $type => $nodeID) {
             if ($nodeID == $this->node->getAttribute('id')) {
                 $errorType = $type;
                 break;
             }
         }
         $nodeIds = $this->parent->getNodeId();
         if (isset($nodeIds['sendcipherKeys']) && isset($nodeIds['sendcipherKeys']) == $this->node->getAttribute('id') && $this->node->getChild("error")->getAttribute('code') == "406") {
             $this->parent->sendSetPreKeys();
         }
         $this->parent->eventManager()->fire("onGetError", array($this->phoneNumber, $this->node->getAttribute('from'), $this->node->getAttribute('id'), $this->node->getChild(0), $errorType));
     }
     if (isset($this->parent->getNodeId()['cipherKeys']) && $this->parent->getNodeId()['cipherKeys'] == $this->node->getAttribute('id')) {
         $users = $this->node->getChild(0)->getChildren();
         foreach ($users as $user) {
             $jid = $user->getAttribute("jid");
             $registrationId = deAdjustId($user->getChild('registration')->getData());
             $identityKey = new IdentityKey(new DjbECPublicKey($user->getChild('identity')->getData()));
             $signedPreKeyId = deAdjustId($user->getChild('skey')->getChild('id')->getData());
             $signedPreKeyPub = new DjbECPublicKey($user->getChild('skey')->getChild('value')->getData());
             $signedPreKeySig = $user->getChild('skey')->getChild('signature')->getData();
             $preKeyId = deAdjustId($user->getChild('key')->getChild('id')->getData());
             $preKeyPublic = new DjbECPublicKey($user->getChild('key')->getChild('value')->getData());
             $preKeyBundle = new PreKeyBundle($registrationId, 1, $preKeyId, $preKeyPublic, $signedPreKeyId, $signedPreKeyPub, $signedPreKeySig, $identityKey);
             $sessionBuilder = new SessionBuilder($this->parent->getAxolotlStore(), $this->parent->getAxolotlStore(), $this->parent->getAxolotlStore(), $this->parent->getAxolotlStore(), ExtractNumber($jid), 1);
             $sessionBuilder->processPreKeyBundle($preKeyBundle);
             if (isset($this->parent->getPendingNodes()[ExtractNumber($jid)])) {
                 foreach ($this->parent->getPendingNodes()[ExtractNumber($jid)] as $pendingNode) {
                     $msgHandler = new MessageHandler($this->parent, $pendingNode);
                     $msgHandler->Process();
                 }
                 unset($this->parent->getPendingNodes()[ExtractNumber($jid)]);
             }
             $this->parent->sendPendingMessages($jid);
         }
     }
 }
예제 #19
0
     }
 } else {
     $switcher_uname = "";
     // probably was a public service or an error
 }
 // 3. send a message to the user (a mail, an SMS, ...)
 $titolo = 'ADA: ' . translateFN('richiesta di servizio');
 $testo = translateFN("Un utente con dati: ");
 $testo .= $name . " " . $surname;
 $testo .= translateFN(" ha richiesto  il servizio: ");
 $testo .= $service_name . ".";
 $testo .= translateFN(" Riceverai un messaggio contenente le proposte di appuntamento. ");
 // $mh = MessageHandler::instance(MultiPort::getDSN($tester));
 // using the previous  MH if exists
 //if (!isset($mh))
 $mh = MessageHandler::instance(MultiPort::getDSN($tester));
 // prepare message to send
 $destinatari = array($username);
 $message3_ha = array();
 $message3_ha['titolo'] = $titolo;
 $message3_ha['testo'] = $testo;
 $message3_ha['destinatari'] = $destinatari;
 $message3_ha['data_ora'] = "now";
 $message3_ha['tipo'] = ADA_MSG_MAIL;
 $message3_ha['mittente'] = $adm_uname;
 // delegate sending to the message handler
 $res3 = $mh->send_message($message3_ha);
 if (AMA_DataHandler::isError($res3)) {
     // $errObj = new ADA_Error($res,translateFN('Impossibile spedire il messaggio'),
     //NULL,NULL,NULL,$error_page.'?err_msg='.urlencode(translateFN('Impossibile spedire il messaggio')));
 }
예제 #20
0
/*
 * YOUR CODE HERE
 */
include_once 'include/StringValidation.inc.php';
include_once 'include/address_book.inc.php';
if (!isset($op)) {
    $op = 'default';
}
$success = HTTP_ROOT_DIR . '/comunica/list_events.php';
$error_page = HTTP_ROOT_DIR . '/comunica/send_event.php';
$title = translateFN('Pubblica appuntamento');
//$rubrica_ok = 0; // Address book not loaded yet
// Has the form been posted?
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($spedisci)) {
        $mh = MessageHandler::instance(MultiPort::getDSN($sess_selected_tester));
        // Initialize errors array
        $errors = array();
        // Trim all submitted data
        $form = $_POST;
        while (list($key, $value) = each($form)) {
            ${$key} = $value;
        }
        if (!isset($destinatari) || DataValidator::validate_not_empty_string($destinatari) === FALSE) {
            $errors['destinatari'] = ADA_EVENT_PROPOSAL_ERROR_RECIPIENT;
        }
        if (!isset($titolo) || DataValidator::validate_not_empty_string($titolo) === FALSE) {
            $errors['titolo'] = ADA_EVENT_PROPOSAL_ERROR_SUBJECT;
        }
        if (($value = ADAEventProposal::canProposeThisDateTime($userObj, $data_evento, $ora_evento, $sess_selected_tester)) !== TRUE) {
            $errors['$data_evento'] = $value;
예제 #21
0
파일: install.php 프로젝트: rmccue/Lilina
/**
 * upgrade() - Run upgrade processes on supplied data
 *
 * {{@internal Missing Long Description}}}
 */
function upgrade()
{
    global $lilina;
    //require_once(LILINA_INCPATH . '/core/plugin-functions.php');
    require_once LILINA_INCPATH . '/core/feed-functions.php';
    require_once LILINA_INCPATH . '/core/version.php';
    require_once LILINA_INCPATH . '/core/misc-functions.php';
    /** Rename possible old files */
    if (@file_exists(LILINA_PATH . '/.myfeeds.data')) {
        rename(LILINA_PATH . '/.myfeeds.data', LILINA_PATH . '/content/system/config/feeds.data');
    } elseif (@file_exists(LILINA_PATH . '/conf/.myfeeds.data')) {
        rename(LILINA_PATH . '/conf/.myfeeds.data', LILINA_PATH . '/content/system/config/feeds.data');
    } elseif (@file_exists(LILINA_PATH . '/conf/.feeds.data')) {
        rename(LILINA_PATH . '/conf/.feeds.data', LILINA_PATH . '/content/system/config/feeds.data');
    } elseif (@file_exists(LILINA_PATH . '/conf/feeds.data')) {
        rename(LILINA_PATH . '/conf/feeds.data', LILINA_PATH . '/content/system/config/feeds.data');
    }
    if (@file_exists(LILINA_PATH . '/conf/settings.php')) {
        rename(LILINA_PATH . '/conf/settings.php', LILINA_PATH . '/content/system/config/settings.php');
    }
    require_once LILINA_PATH . '/inc/core/conf.php';
    /*
    if(@file_exists(LILINA_PATH . '/content/system/config/feeds.data')) {
    	$feeds = file_get_contents(LILINA_PATH . '/content/system/config/feeds.data');
    	$feeds = unserialize( base64_decode($feeds) );
    
    	/** Are we pre-versioned? * /
    	if(!isset($feeds['version'])){
    
    		/** Is this 0.7? * /
    		if(!is_array($feeds['feeds'][0])) {
    			/** 1 dimensional array, each value is a feed URL string * /
    			foreach($feeds['feeds'] as $new_feed) {
    				Feeds::get_instance()->add($new_feed);
    			}
    		}
    
    		/** We must be in between 0.7 and r147, when we started versioning * /
    		elseif(!isset($feeds['feeds'][0]['url'])) {
    			foreach($feeds['feeds'] as $new_feed) {
    				Feeds::get_instance()->add($new_feed['feed'], $new_feed['name']);
    			}
    		}
    
    		/** The feeds are up to date, but we don't have a version * /
    		else {
    		}
    
    	}
    	elseif($feeds['version'] != $lilina['feed-storage']['version']) {
    		/** Note the lack of breaks here, this means the cases cascade * /
    		switch(true) {
    			case $feeds['version'] < 147:
    				/** We had a b0rked upgrader, so we need to make sure everything is okay * /
    				foreach($feeds['feeds'] as $this_feed) {
    					
    				}
    			case $feeds['version'] < 237:
    				/** We moved stuff around this version, but we've handled that above. * /
    		}
    	}
    	else {
    	}
    	global $data;
    	$data = $feeds;
    	$data['version'] = $lilina['feed-storage']['version'];
    	save_feeds();
    } //end file_exists()
    */
    /** Just in case... */
    unset($BASEURL);
    require LILINA_PATH . '/content/system/config/settings.php';
    if (isset($BASEURL) && !empty($BASEURL)) {
        // 0.7 or below
        $raw_php = "<?php\n// What you want to call your Lilina installation\n\$settings['sitename'] = '{$SITETITLE}';\n\n// The URL to your server\n\$settings['baseurl'] = '{$BASEURL}';\n\n// Username and password to log into the administration panel\n// 'pass' is MD5ed\n\$settings['auth'] = array(\n\t\t\t\t\t\t\t'user' => '{$USERNAME}',\n\t\t\t\t\t\t\t'pass' => '" . md5($PASSWORD) . "'\n\t\t\t\t\t\t\t);\n\n// All the enabled plugins, stored in a serialized string\n\$settings['enabled_plugins'] = '';\n\n// Version of these settings; don't change this\n\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";\n?>";
        if (!($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+')) || !is_resource($settings_file)) {
            lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed');
        }
        fputs($settings_file, $raw_php);
        fclose($settings_file);
    } elseif (!isset($settings['settings_version'])) {
        // Between 0.7 and r147
        // Fine to just use existing settings
        $raw_php = file_get_contents(LILINA_PATH . '/content/system/config/settings.php');
        $raw_php = str_replace('?>', "// Version of these settings; don't change this\n" . "\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";\n?>", $raw_php);
        if (!($settings_file = @fopen(LILINA_PATH . '/conf/settings.php', 'w+')) || !is_resource($settings_file)) {
            lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed');
        }
        fputs($settings_file, $raw_php);
        fclose($settings_file);
    } elseif ($settings['settings_version'] != $lilina['settings-storage']['version']) {
        /** Note the lack of breaks here, this means the cases cascade */
        switch (true) {
            case $settings['settings_version'] < 237:
                /** We moved stuff around this version, but we've handled that above. */
            /** We moved stuff around this version, but we've handled that above. */
            case $settings['settings_version'] < 297:
                new_options_297();
            case $settings['settings_version'] < 302:
                new_options_302();
            case $settings['settings_version'] < 339:
                new_options_339();
            case $settings['settings_version'] < 368:
                new_options_368();
            case $settings['settings_version'] < 480:
                new_options_368();
        }
        $raw_php = file_get_contents(LILINA_PATH . '/content/system/config/settings.php');
        $raw_php = str_replace("\$settings['settings_version'] = " . $settings['settings_version'] . ";", "\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";", $raw_php);
        if (!($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+')) || !is_resource($settings_file)) {
            lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed');
        }
        fputs($settings_file, $raw_php);
        fclose($settings_file);
        require_once LILINA_INCPATH . '/core/class-datahandler.php';
        if (!save_options()) {
            lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/options.data failed</p>', 'Upgrade failed');
        }
    }
    $string = '';
    if (count(MessageHandler::get()) === 0) {
        lilina_nice_die('<p>Your installation has been upgraded successfully. Now, <a href="index.php">get back to reading!</a></p>', 'Upgrade Successful');
        return;
    } else {
        $string .= '<p>Your installation has <strong>not</strong> been upgraded successfully. Here\'s the error:</p><ul><li>';
    }
    lilina_nice_die($string . implode('</li><li>', MessageHandler::get()) . '</li></ul>', 'Upgrade failed');
}
예제 #22
0
파일: index.php 프로젝트: Roj/BFERev
define("DB_PASSWORD", "");
define("DB_NAME", "BFERev");
//start the session - no headers to be sent before this
session_start();
$BaseURL = substr(BaseURL, 0, -1);
//include libraries located at ./classes
include "classes/MessageHandler.php";
include "classes/Database.php";
include "classes/URL.php";
include "classes/Template.php";
include "classes/Libraries.php";
include "functions.php";
//Set error handler. Personal error handler handles errors the nice way! :D
set_error_handler(array("MessageHandler", "HandleError"));
//First announcement.
MessageHandler::HandleAnnouncement("Ahoy! We're on alpha! Please, report any bugs you may find.");
//Initialize some classes, analyze the URL and call classes and their methods to render
// i.e. -> /Bloomie/index.php/Blog/12/LeNotBlogFunny includes /pages/Blog.php, initializes class Blog and calls method Render with parameters [12,'LeNotBlogFunny']
$Database = new Database(HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
$URL = new URL();
$Template = new Template();
$Template->set_filenames(array('index' => 'templates/index.html', 'header' => 'templates/head.html', 'footer' => 'templates/footer.html', 'basepage' => 'templates/basepage.html', 'characterpage' => 'templates/basepage.html', 'characterform' => 'templates/charcreationform.html', 'login' => 'templates/login.html', 'inventory' => 'templates/inventory.html'));
$Template->assign_var("ProjectFolder", $BaseURL);
//Call the class requested by the user.
if (!file_exists("pages/" . addslashes($URL->Class) . ".php")) {
    trigger_error("The page you requested does not exist.");
} else {
    include "pages/" . addslashes($URL->Class) . ".php";
    $ClassName = $URL->Class;
    ${$ClassName} = new $ClassName();
    call_user_func_array(array(${$ClassName}, '' . $URL->Function), $URL->Parameters);
예제 #23
0
 public function __set($name, $value)
 {
     $msg = '';
     switch ($value['error']) {
         case UPLOAD_ERR_CANT_WRITE:
             $msg = T('We are experiencing internal errors (%s). Please try again', 1);
             break;
         case UPLOAD_ERR_EXTENSION:
             $msg = T('Extension is not allowed');
             break;
         case UPLOAD_ERR_FORM_SIZE:
             $msg = T('File size was to big (%s)', 1);
             break;
         case UPLOAD_ERR_INI_SIZE:
             $msg = T('File size was to big (%s)', 2);
             break;
         case UPLOAD_ERR_NO_FILE:
             $msg = T('Please select a file to upload');
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $msg = T('We are experiencing internal errors (%s). Please try again', 2);
             break;
         case UPLOAD_ERR_PARTIAL:
             $msg = T('File upload failed - please try again');
             break;
         case UPLOAD_ERR_OK:
         default:
             //Do nothing
             break;
     }
     if ($msg) {
         MessageHandler::instance()->flash($msg, true);
     }
     parent::__set($name, $value);
 }
예제 #24
0
function notify_admin($title, $msg)
{
    $dh = $GLOBALS['dh'];
    $admins_list = $dh->get_admins_ids();
    $admin_id = $admins_list[0][0];
    $admin = $dh->get_admin($admin_id);
    $admin_uname = $admin['username'];
    // primo accesso in ADA
    $mh = new MessageHandler();
    $message_ha['destinatari'] = $admin_uname;
    $message_ha['priorita'] = 1;
    $message_ha['data_ora'] = "now";
    $message_ha['titolo'] = $title;
    $message_ha['testo'] = $msg;
    $message_ha['data_ora'] = "now";
    $message_ha['mittente'] = $admin_uname;
    // e-mail
    $message_ha['tipo'] = ADA_MSG_MAIL;
    $res = $mh->send_message($message_ha);
    // messaggio interno
    $message_ha['tipo'] = ADA_MSG_SIMPLE;
    $res = $mh->send_message($message_ha);
}
예제 #25
0
/**
 * Validate a plugin filename
 *
 * Checks that the file exists and {@link validate_file() is valid file}. If
 * it either condition is not met, returns false and adds an error to the
 * {@see MessageHandler} stack.
 *
 * @since 1.0
 *
 * @param $filename Path to plugin
 * @return bool True if file exists and is valid, else false
 */
function validate_plugin($filename)
{
    switch (validate_file($filename)) {
        case 1:
        case 2:
            MessageHandler::add_error(_r('Invalid plugin path.'));
            break;
        default:
            if (file_exists(get_plugin_dir() . $filename)) {
                return true;
            } else {
                MessageHandler::add_error(_r('Plugin file was not found.'));
            }
    }
    return false;
}
예제 #26
0
  * Obtain a messagehandler instance for the correct tester
  */
 if (MultiPort::isUserBrowsingThePublicTester()) {
     /*
      * In base a event_msg_id, ottenere connessione al tester appropriato
      */
     $data_Ar = MultiPort::geTesterAndMessageId($msg_id);
     $tester = $data_Ar['tester'];
 } else {
     /*
      * We are inside a tester
      */
     $tester = $sess_selected_tester;
 }
 $tester_dsn = MultiPort::getDSN($tester);
 $mh = MessageHandler::instance($tester_dsn);
 if ($selected_date == 0) {
     /*
      * Nessuna tra le date proposte va bene
      */
     $flags = ADA_EVENT_PROPOSAL_NOT_OK | $practitioner_proposal['flags'];
     $message_content = $practitioner_proposal['testo'];
     $message_ha = array('tipo' => ADA_MSG_AGENDA, 'flags' => $flags, 'mittente' => $mittente, 'destinatari' => $destinatari, 'data_ora' => 'now', 'titolo' => $subject, 'testo' => $message_content);
     /*
      * This email message is sent only to the practitioner.
      * Send here.
      */
     $clean_subject = ADAEventProposal::removeEventToken($subject);
     $email_message_ha = array('tipo' => ADA_MSG_MAIL, 'mittente' => $adm_uname, 'destinatari' => $destinatari, 'data_ora' => 'now', 'titolo' => 'ADA: ' . translateFN('a user asks for new event proposal dates'), 'testo' => sprintf(translateFN('Dear practitioner, the user %s is asking you for new event dates for the appointment %s.\\r\\nThank you.'), $userObj->getFullName(), $clean_subject));
     /*
      * Send the email message
예제 #27
0
function admin_header($title, $parent_file = false)
{
    $self = preg_replace('|^.*/admin/|i', '', $_SERVER['PHP_SELF']);
    $self = preg_replace('|^.*/plugins/|i', '', $self);
    header('Content-Type: text/html; charset=utf-8');
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php 
    echo $title;
    ?>
 &mdash; <?php 
    echo get_option('sitename');
    ?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php 
    echo get_option('baseurl');
    ?>
admin/resources/jquery-ui.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="<?php 
    echo get_option('baseurl');
    ?>
admin/resources/core.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="<?php 
    echo get_option('baseurl');
    ?>
admin/resources/full.css" media="screen"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/jquery.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/json2.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/jquery.ui.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/jquery.scrollTo.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
inc/js/humanmsg.js"></script>
<script type="text/javascript" src="<?php 
    echo get_option('baseurl');
    ?>
admin/admin.js"></script>
</head>
<body id="admin-<?php 
    echo $self;
    ?>
" class="admin-page">
<div id="header">
	<p id="sitetitle"><a href="<?php 
    echo get_option('baseurl');
    ?>
"><?php 
    echo get_option('sitename');
    ?>
</a></p>
	<ul id="navigation">
<?php 
    $navigation = array(array(_r('Dashboard'), 'index.php', ''), array(_r('Feeds'), 'feeds.php', 'feeds'), array(_r('Settings'), 'settings.php', 'settings'));
    $navigation = apply_filters('navigation', $navigation);
    $subnavigation = apply_filters('subnavigation', array('index.php' => array(array(_r('Home'), 'index.php', 'home')), 'feeds.php' => array(array(_r('Add/Manage'), 'feeds.php', 'feeds'), array(_r('Import'), 'feed-import.php', 'feeds')), 'settings.php' => array(array(_r('General'), 'settings.php', 'settings'))), $navigation, $self);
    foreach ($navigation as $nav_item) {
        $class = 'item';
        if (strcmp($self, $nav_item[1]) == 0 || $parent_file && $nav_item[1] == $parent_file) {
            $class .= ' current';
        }
        if (isset($subnavigation[$nav_item[1]]) && count($subnavigation[$nav_item[1]]) > 1) {
            $class .= ' has-submenu';
        }
        echo "<li class='{$class}'><a href='{$nav_item[1]}'>{$nav_item[0]}</a>";
        if (!isset($subnavigation[$nav_item[1]]) || count($subnavigation[$nav_item[1]]) < 2) {
            echo "</li>";
            continue;
        }
        echo '<ul class="submenu">';
        foreach ($subnavigation[$nav_item[1]] as $subnav_item) {
            echo '<li' . (strcmp($self, $subnav_item[1]) == 0 ? ' class="current"' : '') . "><a href='{$subnav_item[1]}'>{$subnav_item[0]}</a></li>";
        }
        echo '</ul></li>';
    }
    ?>
			<li id="page_item_logout" class="seperator"><a href="admin.php?logout=logout" title="<?php 
    _e('Log out of your current session');
    ?>
"><?php 
    _e('Log out');
    ?>
</a></li>
	</ul>
</div>
<div id="main">
<?php 
    if ($result = implode('</p><p>', MessageHandler::get())) {
        echo '<div id="alert" class="fade"><p>' . $result . '</p></div>';
    }
    do_action('admin_header');
    do_action("admin_header-{$self}");
    do_action('send_headers');
}
예제 #28
0
<?php

namespace InterestCalculator;

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/config.php';
$messageHandler = new MessageHandler();
$messageHandler->setAmqpFactory(new AMQPFactory());
$messageHandler->setInterestCalculator(new Calculator());
$messageHandler->setListenQueue(RABBIT_MQ_SERVER_LISTEN_QUEUE);
$messageHandler->setBroadcastQueue(RABBIT_MQ_SERVER_BROADCAST_QUEUE);
$messageHandler->setToken(MESSAGE_TOKEN);
$messageHandler->connect(RABBIT_MQ_SERVER_HOST, RABBIT_MQ_SERVER_USER, RABBIT_MQ_SERVER_PASSWORD);
$messageHandler->handle();
예제 #29
0
<?php

/* $Id: test.MessageHandler.php,v 1.1 2004/06/08 11:42:51 mloitzl Exp $
 */
error_reporting(E_ALL);
$DOC_ROOT = $_SERVER['DOCUMENT_ROOT'];
$USER_DIR = '/martin';
$PROJECT_NAME = '/hem';
$APP_ROOT = $DOC_ROOT . $USER_DIR . $PROJECT_NAME;
$PEAR_DIR = $APP_ROOT . '/pear';
$APP_FRAMEWORK_DIR = $APP_ROOT . '/framework';
$APP_FRAMEWORK_CLASSES_DIR = $APP_FRAMEWORK_DIR . '/classes';
$PATH = $PEAR_DIR . $APP_FRAMEWORK_DIR . $APP_FRAMEWORK_CLASSES_DIR;
ini_set(' include_path', ':' . $PATH . ':' . ini_get('include_path'));
$DEFAULT_LANGUAGE = 'US';
require_once 'class.Handler.php';
require_once 'class.MessageHandler.php';
require_once 'test.MessageHandler.messages';
$params = array('caller' => 'test.MessageHandler');
$msg = new MessageHandler($params);
echo "MessageHandler Version " . $msg->apiVersion() . " loaded <br/>";
echo "Loaded MessageHandler with languagecode " . $DEFAULT_LANGUAGE . " <br/>";
$msg->write('SAMPLE_MSG_CODE');
$DEFAULT_LANGUAGE = 'DE';
$msg1 = new MessageHandler($params);
echo "Loaded ErrorHandler with languagecode " . $DEFAULT_LANGUAGE . " <br/>";
$msg1->write('SAMPLE_MSG_CODE');
예제 #30
0
 function get_class_reportFN($id_course, $order = "", $index_att = "", $type = 'HTML')
 {
     $dh = $GLOBALS['dh'];
     $http_root_dir = $GLOBALS['http_root_dir'];
     $debug = isset($GLOBALS['debug']) ? $GLOBALS['debug'] : null;
     $npar = isset($GLOBALS['npar']) ? $GLOBALS['npar'] : null;
     $hpar = isset($GLOBALS['hpar']) ? $GLOBALS['hpar'] : null;
     $mpar = isset($GLOBALS['mpar']) ? $GLOBALS['mpar'] : null;
     $epar = isset($GLOBALS['epar']) ? $GLOBALS['epar'] : null;
     $bpar = isset($GLOBALS['mpar']) ? $GLOBALS['mpar'] : null;
     $cpar = isset($GLOBALS['epar']) ? $GLOBALS['epar'] : null;
     // default parameters for activity index are in configuration file
     if (empty($npar)) {
         $npar = NOTE_PAR;
     }
     // notes
     if (!isset($hpar)) {
         $hpar = HIST_PAR;
     }
     // history
     if (!isset($mpar)) {
         $mpar = MSG_PAR;
     }
     //messages
     if (!isset($epar)) {
         $epar = EXE_PAR;
     }
     // exercises
     if (!isset($bpar)) {
         $bpar = defined('BKM_PAR') ? BKM_PAR : null;
     }
     //bookmarks
     if (!isset($cpar)) {
         $cpar = defined('CHA_PAR') ? CHA_PAR : null;
     }
     // chat
     $student_list_ar = $this->student_list;
     $id_instance = $this->id;
     if ($student_list_ar != 0) {
         $info_course = $dh->get_course($id_course);
         // Get title course
         if (AMA_DataHandler::isError($info_course)) {
             $msg = $info_course->getMessage();
             return $msg;
         }
         $course_title = $info_course['titolo'];
         $instance_course_ha = $dh->course_instance_get($id_instance);
         // Get the instance courses data
         if (AMA_DataHandler::isError($instance_course_ha)) {
             $msg = $instance_course_ha->getMessage();
             return $msg;
         }
         $start_date = AMA_DataHandler::ts_to_date($instance_course_ha['data_inizio'], ADA_DATE_FORMAT);
         $num_student = -1;
         $tot_history_count = 0;
         $tot_exercises_score = 0;
         $tot_exercises_number = 0;
         $tot_added_notes = 0;
         $tot_read_notes = 0;
         $tot_message_count = 0;
         $tot_message_count_in = 0;
         $tot_message_count_out = 0;
         $tot_bookmarks_count = 0;
         $tot_chatlines_count_out = 0;
         $tot_index = 0;
         $tot_level = 0;
         /**
          * @author giorgio 27/ott/2014
          * 
          * change to:
          * $report_generation_TS = time();
          * 
          * to have full date & time generation of report
          * but be warned that table log_classi may grow A LOT!
          */
         $report_generation_TS = dt2tsFN(today_dateFN());
         if (MODULES_TEST) {
             $tot_exercises_score_test = 0;
             $tot_exercises_number_test = 0;
             $tot_exercises_score_survey = 0;
             $tot_exercises_number_survey = 0;
             $test_db = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
             $test_score = $test_db->getStudentsScores($id_course, $id_instance);
         }
         foreach ($student_list_ar as $one_student) {
             $num_student++;
             //starts with 0
             $id_student = $one_student['id_utente_studente'];
             $student_level = $one_student['livello'];
             $status_student = $one_student['status'];
             $dati['id'] = $id_student;
             $dati['level'] = $student_level;
             $ymdhms = today_dateFN();
             $utime = dt2tsFN($ymdhms);
             $dati['date'] = $report_generation_TS;
             if (!empty($id_student) and ($status_student == ADA_STATUS_SUBSCRIBED or $status_student == ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED)) {
                 $studentObj = MultiPort::findUser($id_student);
                 //new Student($id_student,$id_instance);
                 if ($studentObj->full != 0) {
                     //==0) {
                     $err_msg = $studentObj->error_msg;
                 } else {
                     if ($studentObj instanceof ADAPractitioner) {
                         /**
                          * @author giorgio 14/apr/2015
                          * 
                          * If student is actually a tutor, build a new student
                          * object for history and evaluation purposes
                          */
                         $studentObj = $studentObj->toStudent();
                     }
                     $student_name = $studentObj->getFullname();
                     //$studentObj->nome." ".$studentObj->cognome;
                     // vito
                     $studentObj->set_course_instance_for_history($id_instance);
                     //$studentObj->history->setCourseInstance($id_instance);
                     $studentObj->history->setCourse($id_course);
                     $studentObj->get_exercise_dataFN($id_instance, $id_student);
                     $st_exercise_dataAr = $studentObj->user_ex_historyAr;
                     $st_score = 0;
                     $st_exer_number = 0;
                     if (is_array($st_exercise_dataAr)) {
                         foreach ($st_exercise_dataAr as $exercise) {
                             $st_score += $exercise[7];
                             $st_exer_number++;
                         }
                     }
                     $dati['exercises'] = $st_exer_number;
                     $dati['score'] = $st_score;
                     if (MODULES_TEST) {
                         $st_score_test = isset($test_score[$id_student]['score_test']) ? $test_score[$id_student]['score_test'] : 0;
                         $st_exer_number_test = isset($test_score[$id_student]['max_score_test']) ? $test_score[$id_student]['max_score_test'] : 0;
                         $dati['exercises_test'] = $st_exer_number_test;
                         $dati['score_test'] = $st_score_test;
                         $st_score_survey = isset($test_score[$id_student]['score_survey']) ? $test_score[$id_student]['score_survey'] : 0;
                         $st_exer_number_survey = isset($test_score[$id_student]['max_score_survey']) ? $test_score[$id_student]['max_score_survey'] : 0;
                         $dati['exercises_survey'] = $st_exer_number_survey;
                         $dati['score_survey'] = $st_score_survey;
                     }
                     $sub_courses = $dh->get_subscription($id_student, $id_instance);
                     if ($sub_courses['tipo'] == ADA_STATUS_SUBSCRIBED) {
                         $out_fields_ar = array('nome', 'titolo', 'id_istanza', 'data_creazione');
                         $clause = "tipo = '" . ADA_NOTE_TYPE . "' AND id_utente = '{$id_student}'";
                         $nodes = $dh->find_course_nodes_list($out_fields_ar, $clause, $id_course);
                         $added_nodes_count = count($nodes);
                         $added_nodes_count_norm = str_pad($added_nodes_count, 5, "0", STR_PAD_LEFT);
                         $added_notes = "<!-- {$added_nodes_count_norm} --><a href={$http_root_dir}/tutor/tutor.php?op=student_notes&id_instance={$id_instance}&id_student={$id_student}>" . $added_nodes_count . "</a>";
                         //$added_notes = $added_nodes_count;
                     } else {
                         $added_notes = "<!-- 0 -->-";
                     }
                     $read_notes_count = $studentObj->total_visited_notesFN($id_student, $id_course);
                     if ($read_notes_count > 0) {
                         $read_nodes_count_norm = str_pad($read_notes_count, 5, "0", STR_PAD_LEFT);
                         $read_notes = "<!-- {$read_nodes_count_norm} -->{$read_notes_count}";
                     } else {
                         $read_notes = "<!-- 0 -->-";
                     }
                     $st_history_count = "0";
                     $debug = 0;
                     $st_history_count = $studentObj->total_visited_nodesFN($id_student, ADA_LEAF_TYPE);
                     // vito, 11 mar 2009. Ottiene solo il numero di visite a nodi di tipo foglia.
                     // vogliamo anche il numero di visite a nodi di tipo gruppo.
                     $st_history_count += $studentObj->total_visited_nodesFN($id_student, ADA_GROUP_TYPE);
                     $dati['visits'] = $st_history_count;
                     $st_name = "<!-- {$student_name} --><a href=" . $http_root_dir . "/tutor/tutor.php?op=zoom_student&id_student=" . $id_student;
                     $st_name .= "&id_course=" . $id_course . "&id_instance=" . $id_instance . ">";
                     $st_name .= $student_name . "</a>";
                     $st_history_count_norm = str_pad($st_history_count, 5, "0", STR_PAD_LEFT);
                     $st_history = "<!-- {$st_history_count_norm} --><a href=" . $http_root_dir . "/tutor/tutor_history.php?id_student=" . $id_student;
                     $st_history .= "&id_course=" . $id_course . "&id_course_instance=" . $id_instance . ">";
                     $st_history .= $st_history_count . "</a>";
                     $st_history_last_access = $studentObj->get_last_accessFN($id_instance, "T");
                     //$dati['date'] = $st_history_last_access;
                     $st_score_norm = str_pad($st_score, 5, "0", STR_PAD_LEFT);
                     $st_exercises = "<!-- {$st_score_norm} --><a href=" . $http_root_dir . "/tutor/tutor_exercise.php?id_student=" . $id_student;
                     $st_exercises .= "&id_course_instance=" . $id_instance . " class='dontwrap'>";
                     $st_exercises .= $st_score . " " . translateFN("su") . " " . $st_exer_number * ADA_MAX_SCORE . "</a>";
                     if (MODULES_TEST) {
                         $st_score_norm_test = str_pad($st_score_test, 5, "0", STR_PAD_LEFT);
                         $st_exercises_test = '<!-- ' . $st_score_norm_test . ' --><a href="' . MODULES_TEST_HTTP . '/tutor.php?op=test&id_course_instance=' . $id_instance . '&id_course=' . $id_course . '&id_student=' . $id_student . '" class="dontwrap">' . $st_score_test . ' ' . translateFN('su') . ' ' . $st_exer_number_test . '</a>';
                         $st_score_norm_survey = str_pad($st_score_survey, 5, "0", STR_PAD_LEFT);
                         $st_exercises_survey = '<!-- ' . $st_score_norm_survey . ' --><a href="' . MODULES_TEST_HTTP . '/tutor.php?op=survey&id_course_instance=' . $id_instance . '&id_course=' . $id_course . '&id_student=' . $id_student . '" class="dontwrap">' . $st_score_survey . ' ' . translateFN('su') . ' ' . $st_exer_number_survey . '</a>';
                     }
                     // user data
                     $dati_stude[$num_student]['id'] = $id_student;
                     $dati_stude[$num_student]['student'] = $st_name;
                     // history
                     $dati_stude[$num_student]['history'] = $st_history;
                     $tot_history_count += $st_history_count;
                     if ($st_history_last_access != "-") {
                         $dati_stude[$num_student]['last_access'] = "<a href=\"{$http_root_dir}/tutor/tutor_history_details.php?period=1&id_student={$id_student}&id_course_instance={$id_instance}&id_course={$id_course}\">" . $st_history_last_access . "</a>";
                         $dati['last_access'] = $studentObj->get_last_accessFN($id_instance, 'UT');
                     } else {
                         $dati_stude[$num_student]['last_access'] = $st_history_last_access;
                         $dati['last_access'] = null;
                     }
                     // exercises
                     $tot_exercises_score += $st_score;
                     $tot_exercises_number += $st_exer_number;
                     $dati_stude[$num_student]['exercises'] = $st_exercises;
                     $dati['exercises'] = $st_exer_number;
                     if (MODULES_TEST) {
                         $tot_exercises_score_test += $st_score_test;
                         $tot_exercises_number_test += $st_exer_number_test;
                         $dati_stude[$num_student]['exercises_test'] = $st_exercises_test;
                         $dati['exercises_test'] = $st_exer_number_test;
                         $tot_exercises_score_survey += $st_score_survey;
                         $tot_exercises_number_survey += $st_exer_number_survey;
                         $dati_stude[$num_student]['exercises_survey'] = $st_exercises_survey;
                         $dati['exercises_survey'] = $st_exer_number_survey;
                     }
                     // forum notes written
                     $dati_stude[$num_student]['added_notes'] = $added_notes;
                     $tot_added_notes += $added_nodes_count;
                     $dati['added_notes'] = $added_nodes_count;
                     // forum notes read
                     $dati_stude[$num_student]['read_notes'] = $read_notes;
                     $tot_read_notes += $read_notes_count;
                     $dati['read_notes'] = $read_notes_count;
                     // messages
                     //$mh = new MessageHandler("%d/%m/%Y - %H:%M:%S");
                     $mh = MessageHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
                     $sort_field = "data_ora desc";
                     // messages received
                     $msgs_ha = $mh->get_messages($id_student, ADA_MSG_SIMPLE, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['message_count_in'] = "-";
                     } else {
                         $user_message_count = count($msgs_ha);
                         $dati_stude[$num_student]['message_count_in'] = $user_message_count;
                         $tot_message_count += $user_message_count;
                     }
                     $tot_message_count_in += $user_message_count;
                     $dati['msg_in'] = $user_message_count;
                     // messages sent
                     $msgs_ha = $mh->get_sent_messages($id_student, ADA_MSG_SIMPLE, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['message_count_out'] = "-";
                     } else {
                         $user_message_count = count($msgs_ha);
                         $dati_stude[$num_student]['message_count_out'] = $user_message_count;
                         $tot_message_count += $user_message_count;
                     }
                     $tot_message_count_out += $user_message_count;
                     $dati['msg_out'] = $user_message_count;
                     //chat..
                     $msgs_ha = $mh->get_sent_messages($id_student, ADA_MSG_CHAT, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['chat'] = "-";
                     } else {
                         $chatlines_count_out = count($msgs_ha);
                         $dati_stude[$num_student]['chat'] = $chatlines_count_out;
                         $tot_chatlines_count_out += $chatlines_count_out;
                     }
                     $tot_chatlines_count_out += $chatlines_count_out;
                     $dati['chat'] = $chatlines_count_out;
                     //bookmarks..
                     include_once 'bookmark_class.inc.php';
                     $bookmarks_count = count(Bookmark::get_bookmarks($id_student));
                     $dati_stude[$num_student]['bookmarks'] = $bookmarks_count;
                     $tot_bookmarks_count += $bookmarks_count;
                     $dati['bookmarks'] = $bookmarks_count;
                     // activity index
                     if (empty($index_att)) {
                         // parametro passato alla funzione
                         if (empty($GLOBALS['index_activity_expression'])) {
                             //
                             if (!isset($bcount)) {
                                 $bcount = 1;
                             }
                             $index = $added_nodes_count * $npar + $st_history_count * $hpar + $user_message_count * $mpar + $st_exer_number * $epar + $bookmarks_count * $bcount + $chatlines_count_out * $cpar;
                         } else {
                             $index = eval($GLOBALS['index_activity_expression']);
                         }
                     } else {
                         $index = eval($index_att);
                     }
                     $dati_stude[$num_student]['index'] = $index;
                     //echo $index;
                     $tot_index += $index;
                     $dati['index'] = $index;
                     // level
                     $tot_level += $student_level;
                     $dati_stude[$num_student]['level'] = '<span id="studentLevel_' . $id_student . '">' . $student_level . '</span>';
                     $forceUpdate = false;
                     $linksHtml = $this->generateLevelButtons($id_student, $forceUpdate);
                     $dati_stude[$num_student]['level_plus'] = !is_null($linksHtml) ? $linksHtml : '-';
                     // inserting a row in table log_classi
                     $this->log_class_data($id_course, $id_instance, $dati);
                 }
             }
         }
         // average data
         $tot_students = $num_student + 1;
         $av_history = $tot_history_count / $tot_students;
         $av_exercises = $tot_exercises_score / $tot_students . " " . translateFN("su") . " " . floor($tot_exercises_number * ADA_MAX_SCORE / $tot_students);
         if (MODULES_TEST) {
             $av_exercises_test = round($tot_exercises_score_test / $tot_students, 2) . ' ' . translateFN('su') . ' ' . floor($tot_exercises_number_test / $tot_students);
             $av_exercises_survey = round($tot_exercises_score_survey / $tot_students, 2) . ' ' . translateFN('su') . ' ' . floor($tot_exercises_number_survey / $tot_students);
         }
         $av_added_notes = $tot_added_notes / $tot_students;
         $av_read_notes = $tot_read_notes / $tot_students;
         $av_message_count_in = $tot_message_count_in / $tot_students;
         $av_message_count_out = $tot_message_count_out / $tot_students;
         $av_chat_count_out = $tot_chatlines_count_out / $tot_students;
         $av_bookmarks_count = $tot_bookmarks_count / $tot_students;
         $av_index = $tot_index / $tot_students;
         $av_level = $tot_level / $tot_students;
         $av_student = $tot_students;
         $dati_stude[$av_student]['id'] = "-";
         $dati_stude[$av_student]['student'] = translateFN("Media");
         $dati_stude[$av_student]['history'] = round($av_history, 2);
         $dati_stude[$av_student]['last_access'] = "-";
         $dati_stude[$av_student]['exercises'] = '<span class="dontwrap">' . $av_exercises . '</span>';
         if (MODULES_TEST) {
             $dati_stude[$av_student]['exercises_test'] = '<span class="dontwrap">' . $av_exercises_test . '</span>';
             $dati_stude[$av_student]['exercises_survey'] = '<span class="dontwrap">' . $av_exercises_survey . '</span>';
         }
         $dati_stude[$av_student]['added_notes'] = round($av_added_notes, 2);
         $dati_stude[$av_student]['read_notes'] = round($av_read_notes, 2);
         $dati_stude[$av_student]['message_count_in'] = round($av_message_count_in, 2);
         $dati_stude[$av_student]['message_count_out'] = round($av_message_count_out, 2);
         $dati_stude[$av_student]['chat'] = round($av_chat_count_out, 2);
         $dati_stude[$av_student]['bookmarks'] = round($av_bookmarks_count, 2);
         $dati_stude[$av_student]['index'] = round($av_index, 2);
         $dati_stude[$av_student]['level'] = '<span id="averageLevel">' . round($av_level, 2) . '</span>';
         $dati_stude[$av_student]['level_plus'] = "-";
         // @author giorgio 16/mag/2013
         // was $dati_stude[$av_student]['level_minus'] = "-";
         // $dati_stude[$av_student]['level_less'] = "-";
         if (!empty($order)) {
             //var_dump($dati_stude);
             $dati_stude = masort($dati_stude, $order, 1, SORT_NUMERIC);
         }
         // TABLE LABELS
         $table_labels[0] = $this->generate_class_report_header();
         /**
          * @author giorgio 16/mag/2013
          * 
          * unset the unwanted columns data and labels. unwanted cols are defined in config/config_class_report.inc.php
          */
         $arrayToUse = 'report' . $type . 'ColArray';
         $this->clean_class_reportFN($arrayToUse, $table_labels, $dati_stude);
         return array('report_generation_date' => $report_generation_TS) + array_merge($table_labels, $dati_stude);
     } else {
         return null;
     }
 }