Example #1
0
 public function fetchLogs($since_ = NULL)
 {
     Logger::debug('main', 'Starting Server_Logs::fetchLogs for server \'' . $this->server->fqdn . '\'');
     if (is_null($since_)) {
         $since_ = time();
     }
     $ret = query_url($this->server->getWebservicesBaseURL() . '/server/logs/since/' . $since_, false);
     if ($ret === false) {
         $this->server->isUnreachable();
         Logger::error('main', 'Server_Logs::fetchLogs server \'' . $this->server->fqdn . '\' is unreachable');
         return false;
     }
     @file_put_contents($this->logsdir . '/' . date('Ymd') . '.log', $ret . "\n", FILE_APPEND);
     $obj = new FileTailer($this->logsdir . '/' . date('Ymd') . '.log');
     $buf = $obj->tail_str(1);
     if ($buf != '') {
         $buf = preg_match('/^([0-9]+)-([0-9]+)-([0-9]+) ([0-9+]):([0-9]+):([0-9]+),/', $buf, $matches);
         if (is_array($matches) && count($matches) == 7) {
             $last = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
         }
     }
     @file_put_contents($this->logsdir . '/last', isset($last) ? $last : time());
     @file_put_contents($this->logsdir . '/since', time());
     return true;
 }
Example #2
0
 public function get_login()
 {
     $buf = $this->prefs->get('AuthMethod', 'Token');
     $token_url = $buf['url'];
     $user_node_name = $buf['user_node_name'];
     $login_attribute_name = $buf['login_attribute_name'];
     if (!isset($token_url) or $token_url == '') {
         Logger::error('main', 'Token URL is not defined');
         return NULL;
     }
     if (!isset($_REQUEST['token'])) {
         Logger::warning('main', 'Missing parameter : token');
         return NULL;
     }
     $token_url = str_replace('%TOKEN%', $_REQUEST['token'], $token_url);
     $xml = query_url($token_url);
     $dom = new DomDocument('1.0', 'utf-8');
     $ret = @$dom->loadXML($xml);
     if (!$ret) {
         Logger::error('main', 'Token webservice does not send a valid XML');
         return NULL;
     }
     $user_node = $dom->getElementsByTagname($user_node_name)->item(0);
     if (!is_object($user_node)) {
         Logger::error('main', 'Token webservice does not send a valid XML');
         return NULL;
     }
     if (!$user_node->hasAttribute($login_attribute_name)) {
         Logger::error('main', 'Token webservice does not send a valid XML');
         return NULL;
     }
     $this->login = $user_node->getAttribute($login_attribute_name);
     return $this->login;
 }
Example #3
0
 function pager_links($data, $linksCount = 10, $pageKey = 'page')
 {
     if ($data['page'] < 1) {
         $data['page'] = 1;
     }
     $half = floor(($linksCount - 1) / 2);
     $min = $data['page'] - $half;
     if ($min < 1) {
         $min = 1;
     }
     $max = $min + $linksCount;
     if ($max > $data['pagemax'] + 1) {
         $max = $data['pagemax'] + 1;
     }
     $min = $max - $linksCount;
     if ($min < 1) {
         $min = 1;
     }
     $s = '';
     if ($data['page'] > 1) {
         $s .= '<li><a href="' . query_url(['page' => 1]) . '">&laquo;</a></li>';
         $s .= '<li><a href="' . query_url(['page' => $data['page'] - 1]) . '">&lsaquo;</a></li>';
     } else {
         $s .= '<li class="disabled"><a href="' . query_url(['page' => 1]) . '">&laquo;</a></li>';
         $s .= '<li class="disabled"><a href="' . query_url(['page' => 1]) . '">&lsaquo;</a></li>';
     }
     for ($i = $min; $i < $max; $i++) {
         $onstat = '';
         if ($i == $data['page']) {
             $onstat = ' class="active"';
         }
         $s .= '<li' . $onstat . '><a href="' . query_url(['page' => $i]) . '">' . $i . '</a></li>';
     }
     if ($data['page'] < $data['pagemax']) {
         $s .= '<li><a href="' . query_url(['page' => $data['page'] + 1]) . '">&rsaquo;</a></li>';
         $s .= '<li><a href="' . query_url(['page' => $data['pagemax']]) . '">&raquo;</a></li>';
     } else {
         $s .= '<li class="disabled"><a href="' . query_url(['page' => $data['page'] + 1]) . '">&rsaquo;</a></li>';
         $s .= '<li class="disabled"><a href="' . query_url(['page' => $data['pagemax']]) . '">&raquo;</a></li>';
     }
     return '<ul class="pagination">' . $s . '</ul>';
 }
<?php

include locate_template('sections/params/contributors.php');
$url = get_permalink();
$contributors = new WP_Query($contributors_query);
$GLOBALS['wp_query'] = $contributors;
$last_page = $contributors->max_num_pages;
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $contributor_id = $the_ID;
        $title = get_the_title($contributor_id);
        $country = get_field('country', $contributor_id)[0]->post_title;
        $country_slug = get_field('country', $contributor_id)[0]->post_name;
        $country_permalink = query_url('from', $country_slug, $url);
        $permalink = get_permalink();
        $website = get_field('website', $contributor_id);
        $pretty_website = pretty_url($website);
        echo '<div class="contributor shelf-item border-bottom"><div class="inner">';
        echo '<div class="value name">';
        echo '<h3>' . $title . '</h3>';
        echo '</div>';
        echo '<div class="value country"><a href="' . $country_permalink . '">' . $country . '</a></div>';
        if ($website) {
            echo '<div class="value website">';
            echo '<a href="' . $website . '" target="_blank">' . $pretty_website . '</a>';
            echo '</div>';
        }
        echo '</div></div>';
    }
    if ($paged < $last_page) {
Example #5
0
						</div>
					</div>
					<div class="filter-lists">
						<div class="filter-list country <?php 
            echo $slug;
            ?>
" data-filter="country">
							<div class="options">
							<?php 
            $countries = get_posts(array('posts_per_page' => -1, 'post_type' => 'country', 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'publish'));
            foreach ($countries as $country) {
                $country_id = $country->ID;
                $country_slug = $country->post_name;
                $country_title = $country->post_title;
                $page_url = get_permalink(get_page_by_path('support/sponsors')->ID);
                $filter_url = query_url('from', $country_slug, $page_url);
                echo '<div class="option">';
                echo '<a href="' . $filter_url . '" data-value="' . $country_slug . '">';
                echo $country_title;
                echo '<div class="swap">';
                echo '<div class="icon default"></div>';
                echo '<div class="icon hover"></div>';
                echo '</div>';
                echo '</a>';
                echo '</div>';
            }
            ?>
							</div>
						</div>
					</div>
				</div>
Example #6
0
$resident_types = array('artist', 'curator');
foreach ($resident_types as $type) {
    if ($short_slug == 'current' || $page_type == 'sponsor') {
        $type_count = get_resident_count('type', $type, $count_query);
    } else {
        $type_count = true;
    }
    if ($type_count) {
        $classes = $type;
        if ($type_param == $type) {
            $classes .= ' selected';
            $remove = true;
        } else {
            $remove = false;
        }
        $type_title = ucwords($type);
        $filter_url = query_url('type', $type, $page_url, $short_slug, $remove);
        echo '<div class="option ' . $classes . '">';
        echo '<a href="' . $filter_url . '" data-value="' . $type . '">';
        echo '<span class="value">' . $type_title . '</span>';
        echo '<div class="swap">';
        echo '<div class="icon default"></div>';
        echo '<div class="icon hover"></div>';
        echo '</div>';
        echo '</a>';
        echo '</div>';
    }
}
?>
	</div>
</div>
Example #7
0
$event_status = get_event_status($event_id);
$event_date_format = get_event_date($event_id);
$event_thumb = get_thumb($event_id, 'thumb');
$today = date('Ymd');
if (get_field('opening_reception', $event_id) >= $today) {
    $opening = new DateTime(get_field('opening_reception', $event_id));
    $opening = $opening->format('M d, Y');
    $opening_hours = get_field('opening_reception_hours', $event_id);
    if ($opening_hours) {
        $opening .= ', ' . $opening_hours;
    }
}
echo '<div class="event item shelf-item border-bottom ' . $event_status . '" data-id="' . $event_id . '">';
echo '<div class="inner">';
echo '<a class="wrap value date" href="' . $event_url . '">';
echo '<h2 class="link name title">' . $event_title . '</h2>';
echo '<div class="image">';
echo '<img src="' . $event_thumb . '"/>';
echo '</div>';
if ($opening) {
    echo '<div class="value date link">Opening Reception:&nbsp;' . $opening . '</div>';
}
echo '<div class="value date link">' . $event_date_format . '</div>';
echo '</a>';
echo '<div class="value event-type">';
echo '<a href="' . query_url('type', $event_type, site_url() . '/events') . '">';
echo $event_type_name;
echo '</a>';
echo '</div>';
echo '</div></div>';
wp_reset_postdata();
Example #8
0
 public function refresh()
 {
     $server = Abstract_Server::load($this->server);
     if (!is_object($server)) {
         Logger::error('apt-get', 'TASK::refresh for task ' . $this->id . ' returned an error (unknown server ' . $this->server . ')');
         return false;
     }
     $xml = query_url($server->getBaseURL() . '/aps/debian/' . $this->job_id . '/status');
     if (!$xml) {
         Logger::error('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' returned an error');
         $this->status = 'error';
         return true;
     }
     $dom = new DomDocument('1.0', 'utf-8');
     $buf = @$dom->loadXML($xml);
     if (!$buf) {
         return false;
     }
     if (!$dom->hasChildNodes()) {
         return false;
     }
     $node = $dom->getElementsByTagname('debian_request')->item(0);
     if (is_null($node)) {
         return false;
     }
     $this->status = $node->getAttribute('status');
     $ret = true;
     switch ($this->status) {
         case 'created':
             Logger::warning('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' is created');
             $ret = false;
             break;
         case 'in progress':
             Logger::warning('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' is in progress');
             $ret = false;
             break;
         case 'success':
             Logger::info('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' is now finished');
             $this->t_end = time();
             $server->updateApplications();
             $ret = true;
             break;
         case 'error':
             Logger::error('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' returned an error');
             $ret = true;
             break;
     }
     return $ret;
 }
Example #9
0
}
?>
	</div>
</div>

<div class="filter-list sub year <?php 
echo $slug;
?>
" data-filter="year">
	<div class="options">
		<?php 
$start_date = 2010;
$end_date = date('Y');
$years = array_reverse(range($start_date, $end_date));
foreach ($years as $year) {
    $filter_url = query_url('date', $year, $page_url);
    $year_count = get_event_count('year', $year);
    if ($year_count != 0) {
        $classes = 'year';
        if ($year == $year_param) {
            $classes .= ' selected';
        }
        echo '<div class="option ' . $classes . '">';
        echo '<a href="' . $filter_url . '" data-value="' . $year . '">';
        echo $year;
        echo '<div class="swap">';
        echo '<div class="icon default"></div>';
        echo '<div class="icon hover"></div>';
        echo '</div>';
        echo '</a>';
        echo '</div>';
Example #10
0
 public function getInstallableApplications()
 {
     Logger::debug('main', 'Server::getInstallableApplications');
     return query_url($this->getWebservicesBaseURL() . '/installable_applications.php', false);
 }
Example #11
0
 public function application_icon_getFromServer($application_id_, $server_id_)
 {
     $this->check_authorized('viewApplications');
     $applicationDB = ApplicationDB::getInstance();
     $app = $applicationDB->import($application_id_);
     if (!is_object($app)) {
         Logger::error('api', 'Unknown application "' . $id_ . '"');
         return null;
     }
     $server = Abstract_Server::load($server_id_);
     if (!$server) {
         Logger::error('api', 'Unknown server "' . $server_id_ . '"');
         return null;
     }
     if (!$server->isOnline()) {
         return null;
     }
     $ret = query_url($server->getBaseURL() . '/aps/application/icon/' . $app->getAttribute('id'));
     if (!$ret) {
         return null;
     }
     try {
         $mypicture = new Imagick();
         $mypicture->readImageBlob($ret);
     } catch (Exception $e) {
         Logger::error('api', 'Icon from server ' . $server_id_ . ' for application ' . $app->getAttribute('id') . ' is not a valid image');
         return null;
     }
     return base64_encode($ret);
 }
Example #12
0
					</div>
				</div>
				<div class="filter-lists">
					<div class="filter-list country <?php 
echo $slug;
?>
" data-filter="country">
						<div class="options">
							<?php 
$countries = get_posts(array('posts_per_page' => -1, 'post_type' => 'country', 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'publish'));
foreach ($countries as $country) {
    $country_id = $country->ID;
    $country_slug = $country->post_name;
    $country_title = $country->post_title;
    $country_count = get_contributor_count('country', $country_id, $page_query);
    $filter_url = query_url('from', $country_slug, $page_url, $short_slug);
    if ($country_count != 0) {
        if ($country_param == $country_slug) {
            $selected = ' selected';
        } else {
            $selected = null;
        }
        echo '<div class="option' . $selected . '">';
        echo '<a href="' . $filter_url . '" data-value="' . $country_slug . '">';
        echo $country_title;
        // echo ' (<span class="count">';
        // echo $country_count;
        // echo '</span>)';
        echo '<div class="swap">';
        echo '<div class="icon default"></div>';
        echo '<div class="icon hover"></div>';
Example #13
0
function show_icon($id, $applicationDB)
{
    $applicationsGroupDB = ApplicationsGroupDB::getInstance();
    $app = $applicationDB->import($id);
    if (!is_object($app)) {
        return false;
    }
    //     die_error('Unable to import application "'.$id.'"',__FILE__,__LINE__);
    if ($app->getAttribute('static')) {
        redirect('applications_static.php?action=manage&id=' . $app->getAttribute('id'));
    }
    $is_rw = $applicationDB->isWriteable();
    $liaisons = Abstract_Liaison::load('ApplicationServer', $app->getAttribute('id'), NULL);
    $servers = array();
    foreach ($liaisons as $liaison) {
        $server = Abstract_Server::load($liaison->group);
        if (!$server->isOnline()) {
            continue;
        }
        $servers[] = $server;
    }
    page_header();
    echo '<div>';
    echo '<h1><img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>';
    echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">';
    echo '<tr class="title">';
    echo '<th>' . _('Package') . '</th>';
    echo '<th>' . _('Type') . '</th>';
    //   echo '<th>'._('Status').'</th>';
    echo '<th>' . _('Description') . '</th>';
    echo '<th>' . _('Executable') . '</th>';
    echo '</tr>';
    echo '<tr class="content1">';
    echo '<td>' . $app->getAttribute('package') . '</td>';
    echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>';
    //   echo '<td>'.$status.'</td>';
    echo '<td>' . $app->getAttribute('description') . '</td>';
    echo '<td>' . $app->getAttribute('executable_path') . '</td>';
    echo '</tr>';
    echo '</table>';
    echo '<br />';
    echo '<h2>' . _('Select an icon from an Application Server') . '</h2>';
    echo '<table border="0" cellspacing="1" cellpadding="5">';
    foreach ($servers as $server) {
        $ret = query_url($server->getBaseURL() . '/aps/application/icon/' . $app->getAttribute('id'));
        if (!$ret) {
            continue;
        }
        $imgfile = tempnam(NULL, 'ico');
        @file_put_contents($imgfile, $ret);
        try {
            if (class_exists('Imagick')) {
                $imagick = new Imagick();
                $imagick->readImage($imgfile);
            } else {
                if (file_exists($imgfile)) {
                    @unlink($imgfile);
                }
                continue;
            }
        } catch (Exception $e) {
            if (file_exists($imgfile)) {
                @unlink($imgfile);
            }
            continue;
        }
        if (!file_exists($imgfile)) {
            continue;
        }
        echo '<tr>';
        echo '<td style="width: 32px;"><img src="media/image/temp_icon.php?tempnam=' . basename($imgfile) . '" /></td><td><a href="servers.php?action=manage&amp;fqdn=' . $server->getAttribute('fqdn') . '">' . $server->getAttribute('fqdn') . '</a></td><td><form action="actions.php" method="post"><input type="hidden" name="name" value="Application" /><input type="hidden" name="action" value="icon" /><input type="hidden" name="id" value="' . $app->getAttribute('id') . '" /><input type="hidden" name="server" value="' . $server->getAttribute('fqdn') . '" /><input type="submit" value="' . _('Select this icon') . '" /></form></td>';
        echo '</tr>';
    }
    echo '</table>';
    echo '<br />';
    echo '<h2>' . _('Upload an icon') . '</h2>';
    echo '<table border="0" cellspacing="1" cellpadding="5">';
    echo '<tr>';
    echo '<td>';
    echo '<form action="actions.php" method="post" enctype="multipart/form-data" >';
    // form A
    echo '<input type="hidden" name="name" value="Application" />';
    echo '<input type="hidden" name="action" value="icon" />';
    echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
    echo '<input type="file" name="file_icon" /> ';
    echo '<input type="submit" value="' . _('Upload this icon') . '" />';
    echo '</form>';
    echo '</td>';
    echo '</tr>';
    echo '</table>';
    echo '</div>';
    page_footer();
    die;
}