protected function _assign(Dwoo_Data $data)
 {
     $user = $this->_eventData->getUser();
     $user = $user->toArray();
     $data->assign('user', $user);
     return $data;
 }
Пример #2
0
 public function sendCallBack()
 {
     if ($this->request->post('name') && $this->request->post('phone')) {
         $name = $this->request->post('name');
         $phone = $this->request->post('phone');
         $insert = $this->database->insert("callback", array("idate" => time(), "name_rus" => $name, "phone" => $phone));
         if ($insert) {
             $data = new Dwoo_Data();
             $data->assign("date", date("d-m-Y H:s:i", time()));
             $data->assign("name", $name);
             $data->assign("phone", $phone);
             $message = $this->dwoo->get("email/call-me.php", $data);
             $mail = new PHPMailer(true);
             $mail->From = "*****@*****.**";
             $mail->FromName = "Interline";
             $mail->CharSet = "utf-8";
             $mail->Subject = "Обратная связь";
             $mail->IsHTML(true);
             $mail->MsgHTML($message);
             $emails = $this->model->cms_interface()->where("label=", "email-callme")->getOne();
             $emails = strip_tags(trim($emails['content']));
             $emails = explode(",", $emails);
             foreach ($emails as $one) {
                 if (!empty($one)) {
                     $mail->AddAddress(trim($one));
                     $mail->Send();
                     $mail->ClearAddresses();
                 }
             }
             jsonout(array("ok" => 1));
         }
     }
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function render($viewName, Model $model, NotificationCenter $notificationCenter, $output = true)
 {
     Profile::start('Renderer', 'Generate HTML');
     $templateName = $viewName . '.' . static::$templateFileExtension;
     $dwoo = new Dwoo($this->compiledPath, $this->cachePath);
     $dwoo->getLoader()->addDirectory($this->functionsPath);
     Profile::start('Renderer', 'Create template file.');
     $template = new Dwoo_Template_File($templateName);
     $template->setIncludePath($this->getTemplatesPath());
     Profile::stop();
     Profile::start('Renderer', 'Render');
     $dwooData = new Dwoo_Data();
     $dwooData->setData($model->getData());
     $dwooData->assign('errorMessages', $notificationCenter->getErrors());
     $dwooData->assign('successMessages', $notificationCenter->getSuccesses());
     $this->setHeader('Content-type: text/html', $output);
     // I do never output directly from dwoo to have the possibility to show an error page if there was a render error.
     $result = $rendered = $dwoo->get($template, $dwooData, null, false);
     if ($output) {
         echo $result;
     }
     Profile::stop();
     Profile::stop();
     return $output ? null : $rendered;
 }
Пример #4
0
 /**
  * Method that parsed invoice template and returns string
  *
  * All variable that parsed into invoice.pthml template
  * $reservation:
  * $reservation.id
  * $reservation.user_id
  * $reservation.confirmed (Yes, No - translated)
  * $reservation.is_read (Yes, No - translated)
  * $reservation.creation_datetime (In MySQL format: Y-m-d H:m:s)
  * $reservation.modified_datetime (In MySQL format: Y-m-d H:m:s)
  * $reservation.notes
  * $reservation.tax
  * $reservation.paid
  * $reservation.due
  *
  * $customer:
  * $customer.id
  * $customer.title (Translated)
  * $customer.first_name
  * $customer.last_name
  * $customer.address1
  * $customer.address2
  * $customer.state
  * $customer.city
  * $customer.postcode
  * $customer.country
  * $customer.telephone
  * $customer.mobile
  * $customer.email
  * $customer.username
  *
  * $details each detail is an $element:
  * $element.reservation_id
  * $element.unit_id
  * $element.start_datetime (In MySQL format: Y-m-d H:m:s)
  * $element.end_datetime (In MySQL format: Y-m-d H:m:s)
  * $element.total_price
  * $element.unit.id
  * $element.unit.rating (number)
  * $element.unit.published (Yes, No - translated)
  * $element.unit.color (hex color)
  * $element.unit.(all language db field names that are belong to unit type, for example: name, summary, description)
  *
  * $text: all text constants in section 'Admin.Invoice' in languages file, for example $text.BookingReference
  *
  * @param RM_Reservation_Row $reservation
  * @return <type>
  */
 public static function getInvoice(RM_Reservation_Row $reservation)
 {
     $translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN);
     $data = new Dwoo_Data();
     $data->assign('invoice', array('date' => date('d/m/Y')));
     $config = new RM_Config();
     $data->assign('currencysymbol', $config->getCurrencySymbol());
     //TODO: resmania - we need to add discounts and coupons here
     $reservationArray = $reservation->toArray();
     $billing = new RM_Billing();
     $priceCharges = $billing->getPrice($reservation->id);
     $reservationArray['tax'] = $priceCharges->tax;
     $reservationArray['paid'] = $billing->getPaymentsTotal($reservation);
     $reservationArray['due'] = abs($priceCharges->total - $billing->getPaymentsTotal($reservation));
     $reservationArray['total'] = $priceCharges->total;
     $reservationArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo');
     $reservationArray['is_read'] = $reservation->is_read ? $translate->_('MessageYes') : $translate->_('MessageNo');
     $data->assign('reservation', $reservationArray);
     $text = $translate->getSectionMessages('Common.Invoice');
     $data->assign('text', $text);
     $userModel = new RM_Users();
     $user = $userModel->getByReservation($reservation);
     if ($user == null) {
         $userArray = array();
     } else {
         $userArray = $user->toArray();
         $userArray['title'] = $user->getTitle();
     }
     $data->assign('customer', $userArray);
     $reservationDetailsModel = new RM_ReservationDetails();
     $summaryModel = new RM_ReservationSummary();
     $details = $reservationDetailsModel->getAllByReservation($reservation);
     $arrayDetails = array();
     foreach ($details as $detail) {
         $arrayDetail = $detail->toArray();
         $unit = $detail->findUnit();
         $unitArray = $unit->toArray();
         $unitArray['id'] = $unit->getId();
         $unitArray['published'] = $unitArray->published ? $translate->_('MessageYes') : $translate->_('MessageNo');
         // format the start/end dates
         $arrayDetail['start_datetime'] = $config->convertDates($arrayDetail['start_datetime'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT);
         $arrayDetail['end_datetime'] = $config->convertDates($arrayDetail['end_datetime'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT);
         // extras
         $reservationDetailsExtra = $summaryModel->fetchByReservationDetail($detail)->toArray();
         foreach ($reservationDetailsExtra as $extra) {
             if ($extra['value'] == 0) {
                 $extra['value'] = "";
             }
             $unitArray['extras'][] = array("name" => $extra['name'], "value" => $extra['value'], "total_amount" => $extra['total_amount']);
         }
         $arrayDetail['unit'] = $unitArray;
         $arrayDetails[] = $arrayDetail;
     }
     $data->assign('details', $arrayDetails);
     $templateFile = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'views', 'admin', 'scripts', 'templates', 'invoice.phtml'));
     $template = new Dwoo_Template_File($templateFile);
     $dwoo = new Dwoo();
     return $dwoo->get($template, $data);
 }
Пример #5
0
 /**
  * @expectedException Dwoo_Exception
  */
 public function testUnassign()
 {
     $data = new Dwoo_Data();
     $data->variable = 'val';
     $this->assertEquals(true, isset($data->variable));
     $data->unassign('variable');
     $data->get('variable');
 }
Пример #6
0
 public function getYmlTemplate($products, $catalog = false)
 {
     $data = new Dwoo_Data();
     $data->assign("products", $products);
     $data->assign("catalog", $catalog);
     $data->assign("course", $this->course);
     $xml = $this->dwoo->get("xml/yml.php", $data);
     file_put_contents($this->dir . "yml.xml", $xml);
     return $xml;
 }
Пример #7
0
 function GenerateModLogRSS()
 {
     global $tc_db;
     require_once KU_ROOTDIR . 'lib/dwoo.php';
     $dwoo = new Dwoo();
     $dwoo_data = new Dwoo_Data();
     $entries = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "modlog` ORDER BY `timestamp` DESC LIMIT 15");
     $dwoo_data->assign('entries', $entries);
     $rss = $dwoo->get(KU_TEMPLATEDIR . '/rss_mod.tpl', $dwoo_data);
     return $rss;
 }
 protected function _assign(Dwoo_Data $data)
 {
     try {
         $details = $this->_eventData->getAllDetails();
         $arrayDetails = array();
         foreach ($details as $detail) {
             $arrayDetails[] = array('unit' => $detail->getUnit()->toArray(), 'period' => (array) $detail->getPeriod(), 'periodtime' => (array) $detail->getPeriod(true), 'persons' => $detail->getPersons()->getAll(), 'total' => $detail->getTotal());
         }
         $data->assign('details', $arrayDetails);
         $data->assign('user', $this->_eventData->getUser()->toArray());
         $data->assign('reservation_id', $this->_eventData->getReservationID());
     } catch (Exception $e) {
         return false;
     }
     return $data;
 }
Пример #9
0
 public function append($name, $val = null, $merge = false)
 {
     if (is_array($val)) {
         foreach ($val as $k => $v) {
             $this->data[$name][$k] = $v;
         }
     } else {
         parent::append($name, $val, $merge);
     }
 }
Пример #10
0
 public function testAppend()
 {
     $data = new Dwoo_Data();
     $data->assign('var', 'val');
     $data->append('var', 'moo');
     $this->assertEquals(array('var' => array('val', 'moo')), $data->getData());
     $data->assign('var', 'val');
     $data->append(array('var' => 'moo', 'var2' => 'bar'));
     $this->assertEquals(array('var' => array('val', 'moo'), 'var2' => array('bar')), $data->getData());
 }
 protected function _assign(Dwoo_Data $data)
 {
     $details = $this->_eventData->getAllDetails();
     $reservationID = $this->_eventData->getReservationID();
     $reservationModel = new RM_Reservations();
     $reservation = $reservationModel->find($reservationID)->current();
     $arrayDetails = array();
     foreach ($details as $detail) {
         $arrayDetails[] = array('unit' => $detail->getUnit()->toArray(), 'period' => (array) $detail->getPeriod(), 'periodtime' => (array) $detail->getPeriod(true), 'persons' => $detail->getPersons(), 'total' => $detail->getTotal());
     }
     // total paid and total due
     $billing = new RM_Billing();
     $priceCharges = $billing->getPrice($reservationID);
     $billingArray['tax'] = $priceCharges->tax;
     $billingArray['paid'] = $billing->getPaymentsTotal($reservation);
     $billingArray['due'] = $priceCharges->total;
     $billingArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo');
     $data->assign('details', $arrayDetails);
     $data->assign('reservation_id', $this->_eventData->getReservationID());
     return $data;
 }
Пример #12
0
 public function startFollow()
 {
     $filename = APP_DIR . 'cron/block.php';
     $new_array = array();
     $follow_price = $this->model->follow_price()->joined(true)->order("pos ASC")->getByActive(1);
     foreach ($follow_price as $key => $item) {
         $email = strtolower(trim($item['email']));
         $new_array[$email][] = $item;
     }
     foreach ($new_array as $key => $item) {
         foreach ($item as $k => $v) {
             $new_array[$key][$k]['new_price'] = $v['product']['price'];
             if ($v['old_price'] <= $v['product']['price']) {
                 unset($new_array[$key][$k]);
             } else {
                 $this->database->update('follow_price', array('old_price' => $v['new_price'], 'procent' => $v['old_price'] - $v['new_price']), array('id' => $v['id']));
             }
         }
     }
     foreach ($new_array as $key => $item) {
         if (isset($item) && is_array($item) && !empty($item)) {
             $data = new Dwoo_Data();
             $data->assign('products', $item);
             $message = $this->dwoo->get("email/follow-mail.php", $data);
             $mail = new PHPMailer(true);
             $mail->From = "*****@*****.**";
             $mail->FromName = "Interline";
             $mail->CharSet = "utf-8";
             $mail->Subject = "Скидка на товары";
             $mail->IsHTML(true);
             $mail->MsgHTML($message);
             $mail->AddAddress(trim($key));
             $mail->Send();
             $mail->ClearAddresses();
         }
     }
 }
 protected function _assign(Dwoo_Data $data)
 {
     $translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN);
     $locationsDAO = new RM_Locations();
     $reservationID = $this->_eventData->getReservationID();
     $reservationModel = new RM_Reservations();
     $reservation = $reservationModel->find($reservationID)->current();
     // reservation details
     $details = $this->_eventData->getAllDetails();
     $arrayDetails = array();
     foreach ($details as $detail) {
         $unit = $detail->getUnit()->toArray();
         $period = $detail->getPeriod()->toArray();
         $periodWithTime = $detail->getPeriod()->toArray(true);
         $location = $locationsDAO->fetchByUnit($unit['id'])->toArray();
         $extrasForTemplate = array();
         $extras = $detail->getExtras();
         foreach ($extras as $extra) {
             $extrasForTemplate[] = $extra->toArray();
         }
         $arrayDetails[] = array('unit' => $unit, 'locationInfo' => isset($location[0]) ? $location[0] : '', 'period' => $period, 'periodtime' => $periodWithTime, 'persons' => $detail->getPersons()->getAll(), 'total' => $detail->getTotal(), 'extras' => $extrasForTemplate);
     }
     // total paid and total due
     $billing = new RM_Billing();
     $priceCharges = $billing->getPrice($reservationID);
     $billingArray['tax'] = $priceCharges->tax;
     $billingArray['paid'] = $billing->getPaymentsTotal($reservation);
     $billingArray['due'] = $priceCharges->total;
     $billingArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo');
     // return the data to the template
     $data->assign('extras', $extrasForTemplate);
     $data->assign('details', $arrayDetails);
     $data->assign('user', $this->_eventData->getUser()->toArray());
     $data->assign('reservation_id', $reservationID);
     $data->assign('billing', $billingArray);
     return $data;
 }
Пример #14
0
    /**
     *  Parse
     *
     * Parses pseudo-variables contained in the specified template,
     * replacing them with the data in the second param
     *
     * @access	public
     * @param	string
     * @param	array
     * @param	bool
     * @param	string
     * @return	string
     */
    public function _parse_compiled($string, $data, $return = FALSE, $cache_id = NULL)
    {
        // Start benchmark
        $this->_ci->benchmark->mark('dwoo_parse_start');
        // Convert from object to array
        if (!is_array($data)) {
            $data = (array) $data;
        }
        $data = array_merge($this->_ci->load->get_vars(), $data);
        foreach ($this->_parser_assign_refs as $ref) {
            $data[$ref] =& $this->_ci->{$ref};
        }
        // Object containing data
        $dwoo_data = new Dwoo_Data();
        $dwoo_data->setData($data);
        $parsed_string = '';
        try {
            // Object of the template
            $tpl = new Dwoo_Template_String($string, NULL, $cache_id, NULL);
            $dwoo = !isset($this->_dwoo) ? self::spawn() : $this->_dwoo;
            // check for existence of dwoo object... may not be there if folder is not writable
            // added by David McReynolds @ Daylight Studio 1/20/11
            if (!empty($dwoo)) {
                // Create the compiler instance
                $compiler = new Dwoo_Compiler();
                // added by David McReynolds @ Daylight Studio 1/22/12
                $compiler->setDelimiters($this->l_delim, $this->r_delim);
                //Add a pre-processor to help fix javascript {}
                // added by David McReynolds @ Daylight Studio 11/04/10
                $callback = create_function('$compiler', '
					$string = $compiler->getTemplateSource();
					
					$callback = create_function(\'$matches\',
						\'if (isset($matches[1]))
						{
							$str = "<script";
							$str .= preg_replace("#\\' . $this->l_delim . '([^s])#ms", "' . $this->l_delim . ' $1", $matches[1]);
							$str .= "</script>";
							return $str;
						}
						else
						{
							return $matches[0];
						}
						\'
						);

					$string = preg_replace_callback("#<script(.+)</script>#Ums", $callback, $string);
					$compiler->setTemplateSource($string);
					return $string;
				');
                $compiler->addPreProcessor($callback);
                // render the template
                $parsed_string = $dwoo->get($tpl, $dwoo_data, $compiler);
            } else {
                // load FUEL language file because it has the proper error
                // added by David McReynolds @ Daylight Studio 1/20/11
                $this->_ci->load->module_language(FUEL_FOLDER, 'fuel');
                throw new Exception(lang('error_folder_not_writable', $this->_ci->config->item('cache_path')));
            }
        } catch (Exception $e) {
            if (strtolower(get_class($e)) == 'dwoo_exception') {
                echo '<div class="error">' . $e->getMessage() . '</div>';
            } else {
                show_error($e->getMessage());
            }
        }
        // Finish benchmark
        $this->_ci->benchmark->mark('dwoo_parse_end');
        // Return results or not ?
        if (!$return) {
            $this->_ci->output->append_output($parsed_string);
            return;
        }
        return $parsed_string;
    }
Пример #15
0
#
# Although this page repeats some information from
# host_view, it had the concept of Constant Metrics before
# the SLOPE=zero attribute.  It also uses style sheets for clean
# looks. In the future, it may display process information for
# the node as well.
#
# Originally by Federico Sacerdoti <*****@*****.**>
#
# Host is specified in get_context.php.
if (empty($hostname)) {
    print "<h1>Missing a Node Name</h1>";
    return;
}
$tpl = new Dwoo_Template_File(template("show_node.tpl"));
$data = new Dwoo_Data();
$data->assign("extra", template("node_extra.tpl"));
$up = $hosts_up ? 1 : 0;
$class = $up ? "even" : "down";
$data->assign("class", $class);
$data->assign("name", $hostname);
# $metrics is an array of [Metrics][Hostname][NAME|VAL|TYPE|UNITS|SOURCE].
# Find the host's physical location in the cluster.
$hostattrs = $up ? $hosts_up : $hosts_down;
list($rack, $rank, $plane) = findlocation($hostattrs);
$location = $rack < 0 ? "Unknown" : "Rack {$rack}, Rank {$rank}, Plane {$plane}.";
$data->assign("location", $location);
if (isset($hostattrs['ip'])) {
    $data->assign("ip", $hostattrs['ip']);
} else {
    $data->assign("ip", "");
Пример #16
0
<?php

$tpl = new Dwoo_Template_File(template("decompose_graph.tpl"));
$data = new Dwoo_Data();
$data->assign("range", $range);
$graph_type = "line";
$line_width = "2";
$user['view_name'] = isset($_GET["vn"]) ? sanitize($_GET["vn"]) : NULL;
$user['item_id'] = isset($_GET["item_id"]) ? sanitize($_GET["item_id"]) : NULL;
#################################################################################
# Let's check if we are decomposing a composite graph from a view
#################################################################################
if ($user['view_name'] and $user['item_id']) {
    $available_views = get_available_views();
    foreach ($available_views as $id => $view) {
        # Find view settings
        if ($user['view_name'] == $view['view_name']) {
            break;
        }
    }
    unset($available_views);
    foreach ($view['items'] as $index => $graph_config) {
        if ($user['item_id'] == $graph_config['item_id']) {
            break;
        }
    }
    unset($view);
    $title = "";
} else {
    if (isset($_GET['aggregate'])) {
        $graph_config = build_aggregate_graph_config($graph_type, $line_width, $_GET['hreg'], $_GET['mreg']);
Пример #17
0
<?php

ob_start("ob_gzhandler");
require_once './include/include.php';
require_once './include/twilio_config.php';
$dwoo = new Dwoo();
$tpl = new Dwoo_Template_File(TEMPLATE_DIR . '/index.tpl');
$data = new Dwoo_Data();
$server_timezone = new DateTimeZone(date_default_timezone_get());
$local_timezone = new DateTimeZone(TIMEZONE);
try {
    $db = DB::conn();
    $result = $db->Execute('SELECT * FROM ' . DB::$calls . ' ORDER BY ' . DB::$calls_start_time . ' DESC');
    $total_call_duration = 0;
    $total_call_count = $result->RecordCount();
    // This data is used by the JS charting library to display a dot chart
    // showing the calls received each hour. Each slot in the array
    // corresponds to an hour in the day.
    $call_volume_chart_data = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    while ($row = $result->FetchRow()) {
        $from = $row[DB::$calls_from];
        $location = $row[DB::$calls_location];
        $start_time = new DateTime($row[DB::$calls_start_time], $server_timezone);
        $duration = ceil($row[DB::$calls_duration] / 60);
        $total_call_duration += $duration;
        $call_volume_chart_data[$start_time->format('G')] += 1;
        $start_time->setTimezone($local_timezone);
        $call['from'] = format_phone_number($from);
        $call['location'] = $location;
        $call['start_time'] = $start_time->format('F j, Y \\a\\t g:i A');
        $call['duration'] = $duration;
Пример #18
0
<?php

include_once "./global.php";
$tpl = new Dwoo_Template_File(template("compare_hosts.tpl"));
$data = new Dwoo_Data();
$data->assign("range", $range);
$size = isset($clustergraphsize) ? $clustergraphsize : 'default';
//set to 'default' to preserve old behavior
$size = $size == 'medium' ? 'default' : $size;
retrieve_metrics_cache();
$matches = array();
if (array_key_exists('hreg', $_GET)) {
    foreach ($_GET['hreg'] as $key => $query) {
        if ($query != '') {
            foreach ($index_array['hosts'] as $key => $host_name) {
                if (preg_match("/{$query}/i", $host_name)) {
                    // We can have same hostname in multiple clusters
                    foreach ($index_array['cluster'][$host_name] as $clustername) {
                        $matches[] = array("hostname" => $host_name, "clustername" => $clustername);
                    }
                }
            }
        }
    }
}
#print "<PRE>";print_r($index_array['metrics']);
$host_metrics = array();
$host_cluster = array();
foreach ($matches as $index => $match) {
    $hostname = $match['hostname'];
    $host_cluster[] = $match['hostname'] . "|" . $match['clustername'];
Пример #19
0
<?php

/* $Id$ */
$tpl = new Dwoo_Template_File(template("cluster_view.tpl"));
$data = new Dwoo_Data();
$data->assign("extra", template("cluster_extra.tpl"));
$data->assign("images", "./templates/{$template_name}/images");
$cpu_num = !$showhosts ? $metrics["cpu_num"]['SUM'] : cluster_sum("cpu_num", $metrics);
$load_one_sum = !$showhosts ? $metrics["load_one"]['SUM'] : cluster_sum("load_one", $metrics);
$load_five_sum = !$showhosts ? $metrics["load_five"]['SUM'] : cluster_sum("load_five", $metrics);
$load_fifteen_sum = !$showhosts ? $metrics["load_fifteen"]['SUM'] : cluster_sum("load_fifteen", $metrics);
#
# Correct handling of *_report metrics
#
if (!$showhosts) {
    if (array_key_exists($metricname, $metrics)) {
        $units = $metrics[$metricname]['UNITS'];
    }
} else {
    if (array_key_exists($metricname, $metrics[key($metrics)])) {
        if (isset($metrics[key($metrics)][$metricname]['UNITS'])) {
            $units = $metrics[key($metrics)][$metricname]['UNITS'];
        } else {
            $units = '';
        }
    }
}
if (isset($cluster['HOSTS_UP'])) {
    $data->assign("num_nodes", intval($cluster['HOSTS_UP']));
} else {
    $data->assign("num_nodes", 0);
Пример #20
0
 /**
  * Return list of all assigned variables
  *
  * @return array
  */
 public function getVars()
 {
     return $this->_dataProvider->getData();
 }
Пример #21
0
    # Use cookie so we dont have to pass gridstack around within this site.
    # Cookie values are automatically urlencoded. Expires in a day.
    if (!isset($_COOKIE["gs"]) or $_COOKIE["gs"] != $gridstack_str) {
        setcookie("gs", $gridstack_str, time() + 86400);
    }
}
# Invariant: back pointer is second-to-last element of gridstack. Grid stack
# never has duplicate entries.
# RFM - The original line caused an error when count($gridstack) = 1. This
# should fix that.
$parentgrid = $parentlink = NULL;
if (count($gridstack) > 1) {
    list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack) - 2]);
}
$tpl = new Dwoo_Template_File(template("{$header}.tpl"));
$data = new Dwoo_Data();
// Server offset used in generating pretty dates and times when zooming
$data->assign("server_utc_offset", date('Z'));
//
$data->assign("page_title", $title);
$data->assign("refresh", $conf['default_refresh']);
# Templated Logo image
$data->assign("images", "./templates/{$conf['template_name']}/images");
$data->assign("date", date("r"));
# The page to go to when "Get Fresh Data" is pressed.
if (isset($page)) {
    $data->assign("page", $page);
} else {
    $data->assign("page", "./");
}
#
Пример #22
0
    # Use cookie so we dont have to pass gridstack around within this site.
    # Cookie values are automatically urlencoded. Expires in a day.
    if (!isset($_COOKIE["gs"]) or $_COOKIE["gs"] != $gridstack_str) {
        setcookie("gs", $gridstack_str, time() + 86400);
    }
}
# Invariant: back pointer is second-to-last element of gridstack. Grid stack
# never has duplicate entries.
# RFM - The original line caused an error when count($gridstack) = 1. This
# should fix that.
$parentgrid = $parentlink = NULL;
if (count($gridstack) > 1) {
    list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack) - 2]);
}
$tpl = new Dwoo_Template_File(template("{$header}.tpl"));
$data = new Dwoo_Data();
if (isset($_GET["hide-hf"]) && filter_input(INPUT_GET, "hide-hf", FILTER_VALIDATE_BOOLEAN, array("flags" => FILTER_NULL_ON_FAILURE))) {
    $data->assign("hide_header", true);
}
// Server timezone used in generating pretty dates and times when zooming
$data->assign("server_timezone", date_default_timezone_get());
$data->assign("page_title", $title);
$data->assign("refresh", $conf['default_refresh']);
# Templated Logo image
$data->assign("images", "./templates/{$conf['template_name']}/images");
$data->assign("date", date("r"));
# The page to go to when "Get Fresh Data" is pressed.
if (isset($page)) {
    $data->assign("page", $page);
} else {
    $data->assign("page", "./");
Пример #23
0
    ?>
<div class="ui-widget">
  <div class="ui-state-default ui-corner-all" styledefault="padding: 0 .7em;"> 
    <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
    View names valid characters are 0-9, a-z, A-Z, -, _ and space. View has not been created.</p>
  </div>
</div>
<?php 
    exit(0);
} else {
    $view_name = $_GET['vn'];
}
$viewList = new ViewList();
$dwoo = new Dwoo($conf['dwoo_compiled_dir'], $conf['dwoo_cache_dir']);
$tpl = new Dwoo_Template_File(template("view_content.tpl"));
$data = new Dwoo_Data();
$size = isset($clustergraphsize) ? $clustergraphsize : 'default';
// set to 'default' to preserve old behavior
if ($size == 'medium') {
    $size = 'default';
}
$additional_host_img_css_classes = "";
if (isset($conf['zoom_support']) && $conf['zoom_support'] === true) {
    $additional_host_img_css_classes = "host_{$size}_zoomable";
}
$data->assign("additional_host_img_css_classes", $additional_host_img_css_classes);
$view_items = NULL;
$view = $viewList->getView($view_name);
if ($view != NULL) {
    $range = isset($_GET["r"]) ? escapeshellcmd(rawurldecode($_GET["r"])) : NULL;
    $cs = isset($_GET["cs"]) ? escapeshellcmd($_GET["cs"]) : NULL;
Пример #24
0
<?php

/* $Id$ */
#
# Displays the cluster in a physical view. Cluster nodes in
# this view are located by Rack, Rank, and Plane in the physical
# cluster.
#
# Originally written by Federico Sacerdoti <*****@*****.**>
# Part of the Ganglia Project, All Rights Reserved.
#
# Called from index.php, so cluster and xml tree vars
# ($metrics, $clusters, $hosts) are set, and header.php
# already called.
$tpl = new Dwoo_Template_File(template("physical_view.tpl"));
$data = new Dwoo_Data();
$data->assign("cluster", $clustername);
$cluster_url = rawurlencode($clustername);
$data->assign("cluster_url", $cluster_url);
$verbosity_levels = array('3' => "", '2' => "", '1' => "");
# Assign the verbosity level. Can take the value of the 'p' CGI variable.
$verbose = $physical ? $physical : 2;
$verbosity_levels[$verbose] = "checked";
$data->assign("verbosity_levels", $verbosity_levels);
#
# Give the capacities of this cluster: total #CPUs, Memory, Disk, etc.
#
$CPUs = cluster_sum("cpu_num", $metrics);
# Divide by 1024^2 to get Memory in GB.
$Memory = sprintf("%.1f GB", cluster_sum("mem_total", $metrics) / (double) 1048576);
$Disk = cluster_sum("disk_total", $metrics);
 protected function _assign(Dwoo_Data $data)
 {
     $data->assign('reservation_id', $this->_eventData->getReservationID());
     return $data;
 }
Пример #26
0
if (isset($_GET['views_menu'])) {
    if (!$conf['display_views_using_tree']) {
        ?>
<div id="views_menu">
      <?php 
        echo $existing_views;
        ?>
</div>
    <script type="text/javascript">$(function(){$("#views_menu").buttonsetv();});</script>
  <?php 
    } else {
    }
    exit(0);
}
$tpl = new Dwoo_Template_File(template("views_view.tpl"));
$data = new Dwoo_Data();
$data->assign("range", $range);
if (isset($conf['ad-hoc-views']) && $conf['ad-hoc-views'] === true && isset($_GET['ad-hoc-view'])) {
    $is_ad_hoc = true;
}
// Pop up a warning message if there are no available views
// (Disable temporarily, otherwise we can't create views)
if (count($viewList->getViews()) == -1 && !$is_ad_hoc) {
    $error_msg = '
    <div class="ui-widget">
      <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
        <p><span class="ui-icon ui-icon-alert" 
                 style="float: left; margin-right: .3em;"></span> 
	   <strong>Alert:</strong> There are no views defined.</p>
      </div>
    </div>';
Пример #27
0
        } else {
            $col_index++;
        }
    }
    if ($col_index != 0) {
        for ($i = 0; $i < $num_cols * $num_cols - $num_hosts; $i++) {
            $heatmap .= ",{host:\"unused\",load:0}";
        }
        $heatmap .= ']';
    }
    $heatmap .= ']';
    $data->assign("heatmap_data", $heatmap);
}
$fn = "cluster_" . ($refresh ? "refresh" : "view") . ".tpl";
$tpl = new Dwoo_Template_File(template($fn));
$data = new Dwoo_Data();
if (!$refresh) {
    $data->assign("php_gd", function_exists('imagegif') or function_exists('imagepng'));
    $data->assign("extra", template("cluster_extra.tpl"));
    $data->assign("user_may_edit", checkAccess($clustername, GangliaAcl::EDIT, $conf));
    $data->assign("graph_engine", $conf['graph_engine']);
}
$data->assign("cluster", $clustername);
$data->assign("localtimestamp", $cluster['LOCALTIME']);
$data->assign("localtime", date("Y-m-d H:i", $cluster['LOCALTIME']));
get_cluster_overview($showhosts, $metrics, $cluster, $range, $clustername, $data);
$user_metricname = $user['metricname'];
if (!$showhosts) {
    if (array_key_exists($user_metricname, $metrics)) {
        $units = $metrics[$user_metricname]['UNITS'];
    }
Пример #28
0
<?php

/* $Id: grid_tree.php 2372 2010-11-29 19:21:44Z vvuksan $ */
$tpl = new Dwoo_Template_File(template("grid_tree.tpl"));
$data = new Dwoo_Data();
$data->assign("self", "{$self}");
# Not as complicated as before. No depth-first-search, and
# we only show our immediate children.
# Publish past grids in our stack.
$ancestors = $gridstack;
# Take ourself off the end of the stack.
array_pop($ancestors);
if (count($ancestors)) {
    $data->assign("parentgrid", 1);
    $parentgridtable = "";
    $parentgridstack = array();
    foreach ($ancestors as $g) {
        list($name, $link) = explode("@", $g);
        $parentgridstack[] = $g;
        $parentgridstack_url = rawurlencode(join(">", $parentgridstack));
        $parentgridtable .= "<tr><td align=center class=grid>" . "<a href=\"{$link}?t=yes&amp;gw=back&amp;gs={$parentgridstack_url}\">{$name}</a></td></tr>\n";
    }
    $data->assign("parents", $parentgridtable);
}
$gridtable = "";
# Publish our children.
if ($n = count($grid)) {
    $data->assign("n", $n);
    foreach ($grid as $source => $attrs) {
        if ($source == $self) {
            continue;
Пример #29
0
<?php

$tpl = new Dwoo_Template_File(template("footer.tpl"));
$data = new Dwoo_Data();
$data->assign("webfrontend_version", $version["webfrontend"]);
if (isset($_GET["hide-hf"]) && filter_input(INPUT_GET, "hide-hf", FILTER_VALIDATE_BOOLEAN, array("flags" => FILTER_NULL_ON_FAILURE))) {
    $data->assign("hide_footer", true);
}
if ($version["rrdtool"]) {
    $data->assign("rrdtool_version", $version["rrdtool"]);
}
$backend_components = array("gmetad", "gmetad-python", "gmond");
foreach ($backend_components as $backend) {
    if (isset($version[$backend])) {
        $data->assign("webbackend_component", $backend);
        $data->assign("webbackend_version", $version[$backend]);
        break;
    }
}
$data->assign("parsetime", sprintf("%.4f", $parsetime) . "s");
$dwoo->output($tpl, $data);
Пример #30
0
<?php

/* $Id$ */
$tpl = new Dwoo_Template_File(template("meta_view.tpl"));
$data = new Dwoo_Data();
discover_filters();
if (!empty($filter_defs)) {
    $data->assign("filters", $filter_defs);
    $data->assign("choose_filter", $choose_filter);
}
# Find the private clusters.  But no one is emabarrassed in the
# control room (public only!).
if ($context != "control") {
    $private = embarrassed();
}
$source_names = array_keys($grid);
# Build a list of cluster names and randomly pick a smaller subset to
# display for control room mode.  This allows a dedicated host to
# eventually cycle through all the graphs w/o scrolling the mouse.  A bunch
# of these stations could monitor a large grid.
#
# For the standard meta view still display all the hosts.
if ($context == "control") {
    srand((double) microtime() * 1000000);
    shuffle($source_names);
    $subset = array_slice($source_names, 0, abs($controlroom));
    $source_names = $subset;
}
foreach ($source_names as $c) {
    $cpucount = $metrics[$c]["cpu_num"]['SUM'];
    if (!$cpucount) {