Beispiel #1
0
 /**
  * Name: getData
  * 
  * @param type $url link za paginaciju
  * @param type $cookie_name naziv kolacica
  * @param type $is_archive da li je anketa arhivira ili nije; 1 - jeste, 0 - nije
  */
 function getData($url, $cookie_name, $is_archive = 0)
 {
     $q = get_cookie($cookie_name);
     $perPage = $this->input->post('perPage');
     $perP = $perPage ? $perPage : $q;
     $has_error = 0;
     $message = __('Uspesno dobavljeni podaci!!', $this->template['module']);
     // var_dump($message); exit;
     if (is_numeric($this->anketa->getTotalRows($is_archive))) {
         pagination($url, $this->anketa->getTotalRows($is_archive), $perP, '4', 'ankete');
     } else {
         $has_error = 2;
         $message = "Doslo je do greske.";
     }
     $page = uri_segment('4');
     if (!($data = $this->anketa->fetch_ankete($perP, $page, $is_archive))) {
         $has_error = 1;
         $message = __('Trenutno nema anketa!!! Unesite anketu klikom na', $this->template['module']);
     }
     if (!empty($data)) {
         $redni_broj = isset($page) ? $page : 0;
         foreach ($data as $anketa) {
             $anketa->datum_kreiranja = formatDate($anketa->datum_kreiranja);
             $anketa->redni_broj = ++$redni_broj;
         }
     }
     $links = create_links();
     $uri = $page;
     $result = array('data' => $data, 'links' => $links, 'error' => $has_error, 'uri' => $uri, 'poruka' => $message);
     $this->response($result);
 }
Beispiel #2
0
 print "\t<td colspan='2'><hr></td>";
 print "</tr>";
 if (sizeof($custom_fields) > 0) {
     foreach ($custom_fields as $field) {
         # fix for boolean
         if ($field['type'] == "tinyint(1)" || $field['type'] == "boolean") {
             if ($device[$field['name']] == "0") {
                 $device[$field['name']] = "false";
             } elseif ($device[$field['name']] == "1") {
                 $device[$field['name']] = "true";
             } else {
                 $device[$field['name']] = "";
             }
         }
         # create links
         $device[$field['name']] = create_links($device[$field['name']]);
         print "<tr>";
         print "<th>{$field['name']}</th>";
         print "<td>" . $device[$field['name']] . "</d>";
         print "</tr>";
     }
     print "<tr>";
     print "\t<td colspan='2'><hr></td>";
     print "</tr>";
 }
 print "<tr>";
 print "\t<td></td>";
 if ($User->isadmin) {
     print "\t<td class='actions'>";
     print "\t<div class='btn-group'>";
     print "\t\t<button class='btn btn-xs btn-default editSwitch' data-action='edit'   data-switchid='" . $device['id'] . "'><i class='fa fa-gray fa-pencil'></i></button>";
Beispiel #3
0
 if (sizeof($custom_fields) > 0) {
     foreach ($custom_fields as $key => $field) {
         if (strlen($address[$key]) > 0) {
             $address[$key] = str_replace(array("\n", "\r\n"), "<br>", $address[$key]);
             print "<tr>";
             print "\t<th>{$key}</th>";
             print "\t<td>";
             #booleans
             if ($field['type'] == "tinyint(1)") {
                 if ($address[$key] == 0) {
                     print _("No");
                 } elseif ($address[$key] == 1) {
                     print _("Yes");
                 }
             } else {
                 print create_links($address[$key]);
             }
             print "\t</td>";
             print "</tr>";
         }
     }
 }
 # check for temporary shares!
 if ($User->settings->tempShare == 1) {
     foreach (json_decode($User->settings->tempAccess) as $s) {
         if ($s->type == "ipaddresses" && $s->id == $address['id']) {
             if (time() < $s->validity) {
                 $active_shares[] = $s;
             } else {
                 $expired_shares[] = $s;
             }
    function listing($base_query, $md5_get = false)
    {
        global $db_driver, $db_link;
        $md5_i = false;
        if ($md5_get) {
            preg_match('#_(\\d+)$#', $md5_get, $match);
            $md5_i = $match[1];
        }
        $base_query = trim($base_query);
        $base_query = str_cut_end($base_query, ';');
        $query = $base_query;
        $ret = array('msg' => '', 'error' => '', 'data_html' => false);
        $limit = 25;
        $offset = get('offset', 'int');
        $page = floor($offset / $limit + 1);
        if ($query) {
            if (is_select($query) && !preg_match('#\\s+LIMIT\\s+\\d+#i', $query) && !preg_match('#into\\s+outfile\\s+#', $query)) {
                $query = db_limit($query, $offset, $limit);
            } else {
                $limit = false;
            }
            $time = time_start();
            if (!db_is_safe($query, true)) {
                $ret['error'] = 'Detected UPDATE/DELETE without WHERE condition (put WHERE 1=1 if you want to execute this query)';
                return $ret;
            }
            $rs = @db_query($query);
            if ($rs) {
                if ($rs === true) {
                    if ('mysql' == $db_driver) {
                        $affected = mysql_affected_rows($db_link);
                        $time = time_end($time);
                        $ret['data_html'] = '<b>' . $affected . '</b> rows affected.<br>Time: <b>' . $time . '</b> sec';
                        return $ret;
                    }
                } else {
                    if ('pgsql' == $db_driver) {
                        $affected = @pg_affected_rows($rs);
                        if ($affected || preg_match('#^\\s*(DELETE|UPDATE)\\s+#i', $query)) {
                            $time = time_end($time);
                            $ret['data_html'] = '<p><b>' . $affected . '</b> rows affected. Time: <b>' . $time . '</b> sec</p>';
                            return $ret;
                        }
                    }
                }
                $rows = array();
                while ($row = db_row($rs)) {
                    $rows[] = $row;
                    if ($limit) {
                        if (count($rows) == $limit) {
                            break;
                        }
                    }
                }
                db_free($rs);
                if (is_select($base_query)) {
                    $found = @db_one("SELECT COUNT(*) FROM ({$base_query}) AS sub");
                    if (!is_numeric($found) || count($rows) && !$found) {
                        global $COUNT_ERROR;
                        $COUNT_ERROR = ' (COUNT ERROR) ';
                        $found = count($rows);
                    }
                } else {
                    if (count($rows)) {
                        $found = count($rows);
                    } else {
                        $found = false;
                    }
                }
                if ($limit) {
                    $pages = ceil($found / $limit);
                } else {
                    $pages = 1;
                }
                $time = time_end($time);
            } else {
                $ret['error'] = db_error();
                return $ret;
            }
        } else {
            $ret['error'] = 'No query found.';
            return $ret;
        }
        ob_start();
        ?>
	<?php 
        if (is_numeric($found)) {
            ?>
		<p>
			Found: <b><?php 
            echo $found;
            ?>
</b><?php 
            echo isset($GLOBALS['COUNT_ERROR']) ? $GLOBALS['COUNT_ERROR'] : '';
            ?>
.
			Time: <b><?php 
            echo $time;
            ?>
</b> sec.
			<?php 
            $params = array('md5' => $md5_get, 'offset' => get('offset', 'int'));
            if (get('only_marked') || post('only_marked')) {
                $params['only_marked'] = 1;
            }
            if (get('only_select') || post('only_select')) {
                $params['only_select'] = 1;
            }
            ?>
			/ <a href="<?php 
            echo url(self(), $params);
            ?>
">Refetch</a>
			/ Export to CSV:&nbsp;
			
			<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?export=csv&separator=<?php 
            echo urlencode('|');
            ?>
&query=<?php 
            echo base64_encode($base_query);
            ?>
">pipe</a>
			-
			<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?export=csv&separator=<?php 
            echo urlencode("\t");
            ?>
&query=<?php 
            echo base64_encode($base_query);
            ?>
">tab</a>
			-
			<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?export=csv&separator=<?php 
            echo urlencode(',');
            ?>
&query=<?php 
            echo base64_encode($base_query);
            ?>
">comma</a>
			-
			<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?export=csv&separator=<?php 
            echo urlencode(';');
            ?>
&query=<?php 
            echo base64_encode($base_query);
            ?>
">semicolon</a>
		</p>
	<?php 
        } else {
            ?>
		<p>Result: <b>OK</b>. Time: <b><?php 
            echo $time;
            ?>
</b> sec</p>
	<?php 
        }
        ?>

	<?php 
        if (is_numeric($found)) {
            ?>

		<?php 
            if ($pages > 1) {
                ?>
		<p>
			<?php 
                if ($page > 1) {
                    ?>
				<?php 
                    $ofs = ($page - 1) * $limit - $limit;
                    ?>
				<?php 
                    $params = array('md5' => $md5_get, 'offset' => $ofs);
                    if (get('only_marked') || post('only_marked')) {
                        $params['only_marked'] = 1;
                    }
                    if (get('only_select') || post('only_select')) {
                        $params['only_select'] = 1;
                    }
                    ?>
				<a href="<?php 
                    echo url(self(), $params);
                    ?>
">&lt;&lt; Prev</a> &nbsp;
			<?php 
                }
                ?>
			Page <b><?php 
                echo $page;
                ?>
</b> of <b><?php 
                echo $pages;
                ?>
</b> &nbsp;
			<?php 
                if ($pages > $page) {
                    ?>
				<?php 
                    $ofs = $page * $limit;
                    ?>
				<?php 
                    $params = array('md5' => $md5_get, 'offset' => $ofs);
                    if (get('only_marked') || post('only_marked')) {
                        $params['only_marked'] = 1;
                    }
                    if (get('only_select') || post('only_select')) {
                        $params['only_select'] = 1;
                    }
                    ?>
				<a href="<?php 
                    echo url(self(), $params);
                    ?>
">Next &gt;&gt;</a>
			<?php 
                }
                ?>
		</p>
		<?php 
            }
            ?>

		<script>
		function mark_row(tr)
		{
			var els = tr.getElementsByTagName('td');
			if (tr.marked) {
				for (var i = 0; i < els.length; i++) {
					els[i].style.backgroundColor = '';
				}
				tr.marked = false;
			} else {
				tr.marked = true;
				for (var i = 0; i < els.length; i++) {
					els[i].style.backgroundColor = '#ddd';
				}
			}
		}
		</script>

		<?php 
            if ($found) {
                ?>

			<?php 
                $edit_table = table_from_query($base_query);
                if ($edit_table) {
                    $edit_pk = array_first_key($rows[0]);
                    if (is_numeric($edit_pk)) {
                        $edit_table = false;
                    }
                }
                if ($edit_table) {
                    $types = table_types2($edit_table);
                    if ($types && count($types)) {
                        if (in_array($edit_pk, array_keys($types))) {
                            if (!array_col_match_unique($rows, $edit_pk, '#^\\d+$#')) {
                                $edit_pk = guess_pk($rows);
                                if (!$edit_pk) {
                                    $edit_table = false;
                                }
                            }
                        } else {
                            $edit_table = false;
                        }
                    } else {
                        $edit_table = false;
                    }
                }
                $edit_url = '';
                if ($edit_table) {
                    $edit_url = url(self(true), array('action' => 'editrow', 'table' => $edit_table, 'pk' => $edit_pk, 'id' => '%s'));
                }
                ?>

			<table class="ls" cellspacing="1">
			<tr>
				<?php 
                if ($edit_url) {
                    ?>
<th>#</th><?php 
                }
                ?>
				<?php 
                foreach ($rows[0] as $col => $v) {
                    ?>
					<th><?php 
                    echo $col;
                    ?>
</th>
				<?php 
                }
                ?>
			</tr>
			<?php 
                foreach ($rows as $row) {
                    ?>
			<tr ondblclick="mark_row(this)">
				<?php 
                    if ($edit_url) {
                        ?>
					<td><a href="javascript:void(0)" onclick="popup('<?php 
                        echo sprintf($edit_url, $row[$edit_pk]);
                        ?>
', 620, 500)">Edit</a>&nbsp;</td>
				<?php 
                    }
                    ?>
				<?php 
                    $count_cols = 0;
                    foreach ($row as $v) {
                        $count_cols++;
                    }
                    ?>
				<?php 
                    foreach ($row as $k => $v) {
                        ?>
					<?php 
                        if (preg_match('#^\\s*<a[^>]+>[^<]+</a>\\s*$#iU', $v) && strlen(strip_tags($v)) < 50) {
                            $v = strip_tags($v, '<a>');
                            $v = create_links($v);
                        } else {
                            $v = strip_tags($v);
                            $v = str_replace('&nbsp;', ' ', $v);
                            $v = preg_replace('#[ ]+#', ' ', $v);
                            $v = create_links($v);
                            if (!get('full_content') && strlen($v) > 50) {
                                if (1 == $count_cols) {
                                    $v = truncate_html($v, 255);
                                } else {
                                    $v = truncate_html($v, 50);
                                }
                            }
                            // $v = html_once($v); - create_links() disabling
                        }
                        $nl2br = get('nl2br');
                        if (get('full_content')) {
                            $v = str_wrap($v, 80, '<br>', true);
                        }
                        if (get('nl2br')) {
                            $v = nl2br($v);
                        }
                        //$v = stripslashes(stripslashes($v));
                        if (@$types[$k] == 'int' && (preg_match('#time#i', $k) || preg_match('#date#i', $k)) && preg_match('#^\\d+$#', $v)) {
                            $tmp = @date('Y-m-d H:i', $v);
                            if ($tmp) {
                                $v = $tmp;
                            }
                        }
                        global $post;
                        if (str_has($post['sql'], '@gethostbyaddr') && preg_match('#^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$#', $v)) {
                            $v = $v . '<br>' . @gethostbyaddr($v);
                        }
                        ?>
					<td onclick="mark_col(this)" <?php 
                        echo $nl2br ? 'valign="top"' : '';
                        ?>
 nowrap><?php 
                        echo is_null($row[$k]) ? '-' : $v;
                        ?>
</td>
				<?php 
                    }
                    ?>
			</tr>
			<?php 
                }
                ?>
			</table>

		<?php 
            }
            ?>

		<?php 
            if ($pages > 1) {
                ?>
		<p>
			<?php 
                if ($page > 1) {
                    ?>
				<?php 
                    $ofs = ($page - 1) * $limit - $limit;
                    ?>
				<?php 
                    $params = array('md5' => $md5_get, 'offset' => $ofs);
                    if (get('only_marked') || post('only_marked')) {
                        $params['only_marked'] = 1;
                    }
                    if (get('only_select') || post('only_select')) {
                        $params['only_select'] = 1;
                    }
                    ?>
				<a href="<?php 
                    echo url(self(), $params);
                    ?>
">&lt;&lt; Prev</a> &nbsp;
			<?php 
                }
                ?>
			Page <b><?php 
                echo $page;
                ?>
</b> of <b><?php 
                echo $pages;
                ?>
</b> &nbsp;
			<?php 
                if ($pages > $page) {
                    ?>
				<?php 
                    $ofs = $page * $limit;
                    ?>
				<?php 
                    $params = array('md5' => $md5_get, 'offset' => $ofs);
                    if (get('only_marked') || post('only_marked')) {
                        $params['only_marked'] = 1;
                    }
                    if (get('only_select') || post('only_select')) {
                        $params['only_select'] = 1;
                    }
                    ?>
				<a href="<?php 
                    echo url(self(), $params);
                    ?>
">Next &gt;&gt;</a>
			<?php 
                }
                ?>
		</p>
		<?php 
            }
            ?>

	<?php 
        }
        ?>

<?php 
        $cont = ob_get_contents();
        ob_end_clean();
        $ret['data_html'] = $cont;
        return $ret;
    }
Beispiel #5
0
print _('Description');
?>
</th>
		<td><?php 
print $vlan['description'];
?>
</td>
	</tr>

	<?php 
# print custom subnet fields if any
if (sizeof($cfields) > 0) {
    foreach ($cfields as $key => $field) {
        $vlan[$key] = str_replace("\n", "<br>", $vlan[$key]);
        // create links
        $vlan[$key] = create_links($vlan[$key]);
        print "<tr>";
        print "\t<th>{$key}</th>";
        print "\t<td style='vertical-align:top;align:left;'>{$vlan[$key]}</td>";
        print "</tr>";
    }
}
# action button groups
print "<tr>";
print "\t<th style='vertical-align:bottom;align:left;'>" . _('Actions') . "</th>";
print "\t<td style='vertical-align:bottom;align:left;'>";
print "\t<div class='btn-toolbar' style='margin-bottom:0px'>";
print "\t<div class='btn-group'>";
# permissions
if ($User->is_admin(false)) {
    print "\t\t<button class='btn btn-xs btn-default editVLAN' data-action='edit'   data-vlanid='{$vlan['vlanId']}'><i class='fa fa-pencil'></i></button>";
Beispiel #6
0
if (sizeof($custom_fields) > 0) {
    foreach ($custom_fields as $key => $field) {
        if (strlen($subnet[$key]) > 0) {
            $subnet[$key] = str_replace(array("\n", "\r\n"), "<br>", $subnet[$key]);
            $html_custom[] = "<tr>";
            $html_custom[] = "\t<th>{$key}</th>";
            $html_custom[] = "\t<td>";
            #booleans
            if ($field['type'] == "tinyint(1)") {
                if ($subnet[$key] == "0") {
                    $html_custom[] = _("No");
                } elseif ($subnet[$key] == "1") {
                    $html_custom[] = _("Yes");
                }
            } else {
                $html_custom[] = create_links($subnet[$key]);
            }
            $html_custom[] = "\t</td>";
            $html_custom[] = "</tr>";
        }
    }
    # any?
    if (isset($html_custom)) {
        # divider
        print "<tr>";
        print "\t<th><hr></th>";
        print "\t<td></td>";
        print "</tr>";
        print implode("\n", $html_custom);
    }
}
Beispiel #7
0
             }
             print "</tr>";
         }
     }
 }
 //print details
 print '<tr>' . "\n";
 print '	<td class="name">' . $vlan['name'] . '</td>' . "\n";
 print '	<td class="number"><a href="' . create_link("tools", "vlan", $vlan['vlanId']) . '">' . $vlan['number'] . '</a></td>' . "\n";
 print '	<td class="description">' . $vlan['description'] . '</td>' . "\n";
 if (sizeof($custom) > 0) {
     foreach ($custom as $field) {
         if (!in_array($field['name'], $hidden_fields)) {
             print "<td class='customField hidden-xs hidden-sm'>";
             // creat links
             $vlan[$field['name']] = create_links($vlan[$field['name']]);
             //booleans
             if ($field['type'] == "tinyint(1)") {
                 if ($vlan[$field['name']] == "0") {
                     print _("No");
                 } elseif ($vlan[$field['name']] == "1") {
                     print _("Yes");
                 }
             } elseif ($field['type'] == "text") {
                 if (strlen($vlan[$field['name']]) > 0) {
                     print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='" . str_replace("\n", "<br>", $vlan[$field['name']]) . "'>";
                 } else {
                     print "";
                 }
             } else {
                 print $vlan[$field['name']];
Beispiel #8
0
 /**
  * The standard log function for Open-AudIT. Writes logs to a text file in the desired format (json or syslog).
  *
  * @access    public
  *
  * @category  Function
  *
  * @author    Mark Unwin <*****@*****.**>
  *
  * @param     Object    log_details     An object containing details you wish to log
  *
  * @return NULL [logs the provided string to the log file]
  */
 function output()
 {
     error_reporting(E_ALL);
     $CI =& get_instance();
     if ($CI->response->meta->id == 888888888888.0) {
         $CI->response->meta->id = NULL;
         unset($CI->response->data);
         $CI->response->data = array();
     }
     if (!empty($CI->response->data) and count($CI->response->data) > 0) {
         $CI->response->data = output_convert($CI->response->data);
     }
     if (!empty($CI->response->included) and $CI->response->meta->collection != 'scripts') {
         $CI->response->included = output_convert($CI->response->included);
     }
     create_links();
     // if we have errors set, make sure we remove the data object / array
     if (count($CI->response->errors) > 0) {
         unset($CI->response->data);
     } else {
         unset($CI->response->errors);
     }
     switch ($CI->response->meta->format) {
         case 'screen':
             output_screen($CI->response);
             break;
         case 'json_data':
             output_json_data();
             break;
         case 'datatables':
             output_datatables();
             break;
         case 'excel':
             output_excel($CI->response);
             break;
         case 'csv':
             output_csv($CI->response);
             break;
         case 'html':
             output_html($CI->response);
             break;
         case 'table':
             output_report($CI->response);
             break;
         case 'html_formatted':
             output_html_formatted($CI->response);
             break;
         case 'table_formatted':
             output_table_formatted($CI->response);
             break;
         case 'xml':
             output_xml($CI->response);
             break;
         case 'json':
             output_json($CI->response);
             break;
         case 'rss':
             output_rss($CI->response);
             break;
         case 'pdf':
             // TODO: need to insert the PDF function here
             output_screen($CI->response);
             break;
         case 'doc':
             // TODO: need to insert the doc / docx function here
             output_screen($CI->response);
             break;
         default:
             output_screen($CI->response);
             break;
     }
 }
Beispiel #9
0
 # loop
 foreach ($all_vrfs as $vrf) {
     //cast
     $vrf = (array) $vrf;
     //print details
     print '<tr>' . "\n";
     print '	<td class="name">' . $vrf['name'] . '</td>' . "\n";
     print '	<td class="rd">' . $vrf['rd'] . '</td>' . "\n";
     print '	<td class="description">' . $vrf['description'] . '</td>' . "\n";
     // custom fields
     if (sizeof($custom) > 0) {
         foreach ($custom as $field) {
             if (!in_array($field['name'], $hidden_fields)) {
                 print "<td class='customField hidden-xs hidden-sm'>";
                 // create links
                 $vrf[$field['name']] = create_links($vrf[$field['name']]);
                 //booleans
                 if ($field['type'] == "tinyint(1)") {
                     if ($vrf[$field['name']] == "0") {
                         print _("No");
                     } elseif ($vrf[$field['name']] == "1") {
                         print _("Yes");
                     }
                 } elseif ($field['type'] == "text") {
                     if (strlen($vrf[$field['name']]) > 0) {
                         print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='" . str_replace("\n", "<br>", $vrf[$field['name']]) . "'>";
                     } else {
                         print "";
                     }
                 } else {
                     print $vrf[$field['name']];
Beispiel #10
0
}
$partPath = "";
function create_links($folder)
{
    global $partPath;
    $folders = explode("_", str_replace(".html", "", $folder));
    foreach ($folders as $id => $part) {
        $partPath .= $part;
        echo "<a href=\"index.php?folder={$partPath}\">{$part}</a>";
        if ($id < sizeof($folders) - 1) {
            echo "/";
            $partPath .= "_";
        }
    }
}
create_links($folder);
$date = "20120919";
$csv = file_get_contents("update/coverage_" . $folder . ".csv");
$csv_lines = explode("\n", $csv);
$dates = explode(",", $csv_lines[0]);
$last_date = $dates[sizeof($dates) - 1];
$last_date = str_replace("/", "", $last_date);
?>
 (<a href="phpcoverage/<?php 
echo $last_date . "/" . $partPath;
?>
.html">PHP CodeCoverage</a>)
		<br/>
	<?php 
$subfolderLinks = array();
$subfolders = scandir("update/");
Beispiel #11
0
 }
 # print port
 if (in_array('port', $selected_ip_fields)) {
     print "<td class='hidden-xs hidden-sm hidden-md'>" . $addresses[$n]->port . "</td>";
 }
 # print owner
 if (in_array('owner', $selected_ip_fields)) {
     print "<td class='hidden-xs hidden-sm'>" . $addresses[$n]->owner . "</td>";
 }
 # print custom fields
 if (sizeof($custom_fields) > 0) {
     foreach ($custom_fields as $myField) {
         if (!in_array($myField['name'], $hidden_cfields)) {
             print "<td class='customField hidden-xs hidden-sm hidden-md'>";
             // create html links
             $addresses[$n]->{$myField}['name'] = create_links($addresses[$n]->{$myField}['name']);
             //booleans
             if ($myField['type'] == "tinyint(1)") {
                 if ($addresses[$n]->{$myField}['name'] == "0") {
                     print _("No");
                 } elseif ($addresses[$n]->{$myField}['name'] == "1") {
                     print _("Yes");
                 }
             } elseif ($myField['type'] == "text") {
                 if (strlen($addresses[$n]->{$myField}['name']) > 0) {
                     print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='" . str_replace("\n", "<br>", $addresses[$n][$myField['name']]) . "'>";
                 } else {
                     print "";
                 }
             } else {
                 print $addresses[$n]->{$myField}['name'];
Beispiel #12
0
    function listing($base_query, $md5_get = false)
    {
        // @listing
        GET("full_content", "bool");
        GET("only_select", "bool");
        GET("offset", "int");
        POST("full_content", "bool");
        POST("only_select", "bool");
        global $db_driver, $db_link;
        $full_content = $_GET["full_content"] || $_POST["full_content"];
        $md5_i = false;
        if ($md5_get) {
            preg_match('#_(\\d+)$#', $md5_get, $match);
            $md5_i = $match[1];
        }
        $base_query = trim($base_query);
        if (";" == substr($base_query, -1)) {
            $base_query = substr($base_query, 0, -1);
        }
        $query = $base_query;
        $ret = array('msg' => '', 'error' => '', 'data_html' => false);
        $limit = 25;
        $offset = $_GET["offset"];
        $page = floor($offset / $limit + 1);
        if ($query) {
            if (is_select($query) && !preg_match('#\\s+LIMIT\\s+\\d+#i', $query) && !preg_match('#into\\s+outfile\\s+#', $query)) {
                $query = db_limit($query, $offset, $limit);
            } else {
                $limit = false;
            }
            $time = time_start();
            if (!db_is_safe($query, true)) {
                $ret['error'] = 'Detected UPDATE/DELETE without WHERE condition (put WHERE 1=1 if you want to execute this query)';
                return $ret;
            }
            $rs = @db_query($query);
            if ($rs) {
                if ($rs === true) {
                    if ('mysql' == $db_driver) {
                        $affected = mysql_affected_rows($db_link);
                        $time = time_end($time);
                        $ret['data_html'] = '<b>' . $affected . '</b> rows affected.<br>Time: <b>' . $time . '</b> sec';
                        return $ret;
                    }
                } else {
                    if ('pgsql' == $db_driver) {
                        $affected = @pg_affected_rows($rs);
                        if ($affected || preg_match('#^\\s*(DELETE|UPDATE)\\s+#i', $query)) {
                            $time = time_end($time);
                            $ret['data_html'] = '<p><b>' . $affected . '</b> rows affected. Time: <b>' . $time . '</b> sec</p>';
                            return $ret;
                        }
                    }
                }
                $rows = array();
                while ($row = db_row($rs)) {
                    $rows[] = $row;
                    if ($limit) {
                        if (count($rows) == $limit) {
                            break;
                        }
                    }
                }
                db_free($rs);
                if (is_select($base_query)) {
                    $found = @db_one("SELECT COUNT(*) FROM ({$base_query}) AS sub");
                    if (!is_numeric($found) || count($rows) && !$found) {
                        global $COUNT_ERROR;
                        $COUNT_ERROR = ' (COUNT ERROR) ';
                        $found = count($rows);
                    }
                } else {
                    if (count($rows)) {
                        $found = count($rows);
                    } else {
                        $found = false;
                    }
                }
                if ($limit) {
                    $pages = ceil($found / $limit);
                } else {
                    $pages = 1;
                }
                $time = time_end($time);
            } else {
                $ret['error'] = db_error();
                return $ret;
            }
        } else {
            $ret['error'] = 'No query found.';
            return $ret;
        }
        ob_start();
        // ----------------------------------------------------------------
        // @sqleditor LISTING HTML
        // ----------------------------------------------------------------
        ?>
		<?php 
        if (is_numeric($found)) {
            ?>
			<p>
				Found: <b><?php 
            echo $found;
            ?>
</b><?php 
            echo isset($GLOBALS['COUNT_ERROR']) ? $GLOBALS['COUNT_ERROR'] : '';
            ?>
.
				Time: <b><?php 
            echo $time;
            ?>
</b> sec.
				<?php 
            $params = array('md5' => $md5_get, 'offset' => $_GET["offset"]);
            if ($_GET['only_select'] || $_POST['only_select']) {
                $params['only_select'] = 1;
            }
            if ($_GET['full_content'] || $_POST['full_content']) {
                $params['full_content'] = 1;
            }
            ?>
				/ <a href="<?php 
            echo url(self(), $params);
            ?>
">Refetch</a>
				/ Export to CSV:&nbsp;

				<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?export=csv&separator=<?php 
            echo urlencode('|');
            ?>
&query=<?php 
            echo base64_encode($base_query);
            ?>
">pipe</a>
				-
				<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?export=csv&separator=<?php 
            echo urlencode("\t");
            ?>
&query=<?php 
            echo base64_encode($base_query);
            ?>
">tab</a>
				-
				<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?export=csv&separator=<?php 
            echo urlencode(',');
            ?>
&query=<?php 
            echo base64_encode($base_query);
            ?>
">comma</a>
				-
				<a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?export=csv&separator=<?php 
            echo urlencode(';');
            ?>
&query=<?php 
            echo base64_encode($base_query);
            ?>
">semicolon</a>
			</p>
		<?php 
        } else {
            ?>
			<p>Result: <b>OK</b>. Time: <b><?php 
            echo $time;
            ?>
</b> sec</p>
		<?php 
        }
        ?>

		<?php 
        if (is_numeric($found)) {
            ?>

			<?php 
            if ($pages > 1) {
                ?>
			<p>
				<?php 
                if ($page > 1) {
                    ?>
					<?php 
                    $ofs = ($page - 1) * $limit - $limit;
                    ?>
					<?php 
                    $params = array('md5' => $md5_get, 'offset' => $ofs);
                    if ($_GET['only_select'] || $_POST['only_select']) {
                        $params['only_select'] = 1;
                    }
                    ?>
					<a href="<?php 
                    echo url(self(), $params);
                    ?>
">&lt;&lt; Prev</a> &nbsp;
				<?php 
                }
                ?>
				Page <b><?php 
                echo $page;
                ?>
</b> of <b><?php 
                echo $pages;
                ?>
</b> &nbsp;
				<?php 
                if ($pages > $page) {
                    ?>
					<?php 
                    $ofs = $page * $limit;
                    ?>
					<?php 
                    $params = array('md5' => $md5_get, 'offset' => $ofs);
                    if ($_GET['only_select'] || $_POST['only_select']) {
                        $params['only_select'] = 1;
                    }
                    ?>
					<a href="<?php 
                    echo url(self(), $params);
                    ?>
">Next &gt;&gt;</a>
				<?php 
                }
                ?>
			</p>
			<?php 
            }
            ?>

			<?php 
            if ($found) {
                ?>

				<?php 
                $edit_table = table_from_query($base_query);
                if ($edit_table) {
                    $edit_pk = array_first_key($rows[0]);
                    if (is_numeric($edit_pk)) {
                        $edit_table = false;
                    }
                }
                if ($edit_table) {
                    $types = table_columns($edit_table);
                    if ($types && count($types)) {
                        if (in_array($edit_pk, array_keys($types))) {
                            if (!array_col_match_unique($rows, $edit_pk, '#^\\d+$#')) {
                                $edit_pk = guess_pk($rows);
                                if (!$edit_pk) {
                                    $edit_table = false;
                                }
                            }
                        } else {
                            $edit_table = false;
                        }
                    } else {
                        $edit_table = false;
                    }
                }
                $edit_url = '';
                if ($edit_table) {
                    $edit_url = url(self(true), array('action' => 'editrow', 'table' => $edit_table, 'pk' => $edit_pk, 'id' => '%s'));
                }
                ?>

				<table class="ls" cellspacing="1">
				<tr>
					<?php 
                if ($edit_url) {
                    ?>
<th>#</th><?php 
                }
                ?>
					<?php 
                foreach ($rows[0] as $col => $v) {
                    ?>
						<th><?php 
                    echo $col;
                    ?>
</th>
					<?php 
                }
                ?>
				</tr>
				<?php 
                foreach ($rows as $row) {
                    ?>
				<tr onclick="mark_row(this, event)">
					<?php 
                    if ($edit_url) {
                        ?>
						<td valign=top><a href="javascript:void(0)" onclick="popup('<?php 
                        echo sprintf($edit_url, $row[$edit_pk]);
                        ?>
', <?php 
                        echo EDITROW_POPUP_WIDTH;
                        ?>
, <?php 
                        echo EDITROW_POPUP_HEIGHT;
                        ?>
)">Edit</a>&nbsp;</td>
					<?php 
                    }
                    ?>
					<?php 
                    $count_cols = 0;
                    foreach ($row as $v) {
                        $count_cols++;
                    }
                    ?>
					<?php 
                    foreach ($row as $k => $v) {
                        ?>
						<?php 
                        if (preg_match('#^\\s*<a[^>]+>[^<]+</a>\\s*$#iU', $v) && strlen(strip_tags($v)) < 50) {
                            $v = strip_tags($v, '<a>');
                            $v = create_links($v);
                        } else {
                            $v = strip_tags($v);
                            $v = str_replace('&nbsp;', ' ', $v);
                            $v = preg_replace('#[ ]+#', ' ', $v);
                            $v = create_links($v);
                            if (!$full_content && strlen($v) > 50) {
                                if (1 == $count_cols) {
                                    $v = truncate_html($v, 255);
                                } else {
                                    $v = truncate_html($v, 50);
                                }
                            }
                            // $v = html_once($v); - create_links() disabling
                        }
                        if ($full_content) {
                            $v = str_wrap($v, 80, '<br>', true);
                        }
                        if ($full_content) {
                            $v = nl2br($v);
                        }
                        //$v = stripslashes(stripslashes($v));
                        if (isset($types[$k]) && $types && $types[$k] == 'int' && IsTimestampColumn($k, $v)) {
                            // 100 000 000 == 1973-03-03 10:46:40
                            // Only big integers change to dates, so a low one like "1054"
                            // does not get changed into a date, cause that would probably be wrong.
                            $tmp = date('Y-m-d H:i', $v);
                            if ($tmp) {
                                $v = $tmp;
                            }
                        }
                        ?>
						<td <?php 
                        echo $full_content ? 'valign="top"' : '';
                        ?>
 nowrap><?php 
                        echo is_null($row[$k]) ? '-' : $v;
                        ?>
</td>
					<?php 
                    }
                    ?>
				</tr>
				<?php 
                }
                ?>
				</table>

			<?php 
            }
            ?>

			<?php 
            if ($pages > 1) {
                ?>
			<p>
				<?php 
                if ($page > 1) {
                    ?>
					<?php 
                    $ofs = ($page - 1) * $limit - $limit;
                    ?>
					<?php 
                    $params = array('md5' => $md5_get, 'offset' => $ofs);
                    if ($_GET['only_select'] || $_POST['only_select']) {
                        $params['only_select'] = 1;
                    }
                    ?>
					<a href="<?php 
                    echo url(self(), $params);
                    ?>
">&lt;&lt; Prev</a> &nbsp;
				<?php 
                }
                ?>
				Page <b><?php 
                echo $page;
                ?>
</b> of <b><?php 
                echo $pages;
                ?>
</b> &nbsp;
				<?php 
                if ($pages > $page) {
                    ?>
					<?php 
                    $ofs = $page * $limit;
                    ?>
					<?php 
                    $params = array('md5' => $md5_get, 'offset' => $ofs);
                    if ($_GET['only_select'] || $_POST['only_select']) {
                        $params['only_select'] = 1;
                    }
                    ?>
					<a href="<?php 
                    echo url(self(), $params);
                    ?>
">Next &gt;&gt;</a>
				<?php 
                }
                ?>
			</p>
			<?php 
            }
            ?>

		<?php 
        }
        ?>

	<?php 
        $cont = ob_get_contents();
        ob_end_clean();
        $ret['data_html'] = $cont;
        return $ret;
    }
Beispiel #13
0
 if ($k == 0) {
     //set odd / even
     $n = @$n == 1 ? 0 : 1;
     $class = $n == 0 ? "odd" : "even";
     //start - VLAN details
     print "<tr class='{$class} change'>";
     print "\t<td><a href='" . create_link("tools", "vlan", $vlan_domain->id, $vlan[0]->vlanId) . "'>" . $vlan[0]->number . "</td>";
     print "\t<td>" . $vlan[0]->name . "</td>";
     print "\t<td>" . $vlan[0]->description . "</td>";
     //custom fields - no subnets
     if (sizeof(@$custom_fields) > 0) {
         foreach ($custom_fields as $field) {
             # hidden
             if (!in_array($field['name'], $hidden_fields)) {
                 // create links
                 $v->{$field}['name'] = create_links($v->{$field}['name']);
                 print "<td class='hidden-xs hidden-sm hidden-md'>";
                 //booleans
                 if ($field['type'] == "tinyint(1)") {
                     if ($v->{$field}['name'] == "0") {
                         print _("No");
                     } elseif ($v->{$field}['name'] == "1") {
                         print _("Yes");
                     }
                 } elseif ($field['type'] == "text") {
                     if (strlen($v->{$field}['name']) > 0) {
                         print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='" . str_replace("\n", "<br>", $vlan[$field['name']]) . "'>";
                     } else {
                         print "";
                     }
                 } else {
Beispiel #14
0
		<td><?php 
print $vrf->description;
?>
</td>
	</tr>

	<?php 
# print custom subnet fields if any
if (sizeof($cfields) > 0) {
    // divider
    print "<tr><td><hr></td><td></td></tr>";
    // fields
    foreach ($cfields as $key => $field) {
        $vrf->{$key} = str_replace("\n", "<br>", $vrf->{$key});
        // create links
        $vrf->{$key} = create_links($vrf->{$key});
        print "<tr>";
        print "\t<th>{$key}</th>";
        print "\t<td style='vertical-align:top;align:left;'>" . $vrf->{$key} . "</td>";
        print "</tr>";
    }
    // divider
    print "<tr><td><hr></td><td></td></tr>";
}
# action button groups
print "<tr>";
print "\t<th style='vertical-align:bottom;align:left;'>" . _('Actions') . "</th>";
print "\t<td style='vertical-align:bottom;align:left;'>";
print "\t<div class='btn-toolbar' style='margin-bottom:0px'>";
print "\t<div class='btn-group'>";
# permissions
usort($questions_selected, 'compare_category_weights');
//ensure GET[rot] is ok
if (!(isset($_GET['rot']) and in_array($_GET['rot'], [1, 2]))) {
    if (count($questions_selected) >= count($parliaments_selected)) {
        $_GET['rot'] = 2;
    } else {
        $_GET['rot'] = 1;
    }
    $force_rot = false;
} else {
    $force_rot = true;
}
//select data
$data_selected = select_data($data, $parliaments_selected, $questions_selected);
//create links
$data_selected = create_links($data_selected);
//get best practices
$best_practices = best_practices('good-practices');
//read info.md
//include('../Parsedown.php');
$mdurl = TEXT_URL . lang($page) . "/explore/info.md";
$contents = file_get_contents($mdurl);
$Parsedown = new Parsedown();
$smarty->assign('info_text', ltrim($Parsedown->text($contents), '<p>'));
//filters data by parameters cc and p
//$data = filter_data($data,$questions,$_GET);
//filter questions, put into array and sort them
//$questions_order = filter_questions($questions);
$smarty->assign('get', $_GET);
$smarty->assign('query_string', $_SERVER['QUERY_STRING']);
$smarty->assign('force_rot', $force_rot);
Beispiel #16
0
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
	<?php 
addSiteReqs();
?>
</head>
<body>
	<?php 
showSiteNavigation();
if ($info != false) {
    // add one to our view counter variable
    update_view_count($_GET["v"]);
    // if they are logged in, add this video to their history
    if (isset($_SESSION['loggedin']) && $_SESSION['loggedin']) {
        add_video_to_history($_GET["v"]);
    }
    $links = create_links($info["seriesName"], $info["seriesPos"], $info["name"]);
    $prev_and_next_links = get_prev_and_next_links($info["seriesName"], $info["seriesPos"]);
    ?>
	<div class="video-container">
		<h2><?php 
    echo $info["seriesName"];
    ?>
 <br /> <?php 
    echo "Episode " . $info["seriesPos"] . ": " . $info["name"];
    ?>
</h2>
		<video id="video" controls preload="auto" autoplay width="600px" height="390px" oncontextmenu="return false;">
			<source id="videosrc" src="<?php 
    echo $links["videoLink"];
    ?>
" type="video/mp4" >