function get_status($disabled = false, $makediff = true, $stats = false) { global $somethingstaged, $gitpath; static $firstrun; if (!isset($firstrun)) { $firstrun = true; } else { $firstrun = false; } if (!$firstrun) { echo close_and_add_filelist_parent(); } $result = array('lines' => array()); $somethingstaged = false; clearstatcache(); $h = start_command($gitpath, array('status', '--porcelain'), false); if ($h === false) { return error('command failed to start'); } else { close_stdin($h); $err = ''; $out = ''; while (!is_done($h)) { $line = get_stdout_line($h); if ($line != '') { debug($line); $parsed = parse_line($line); $int = interpret($parsed, $disabled, $makediff, $stats); if ($int !== false) { if (isset($int['dir'])) { $list = array(); $list = add_directory_listing($parsed['dir'], $disabled, $makediff, $stats, $list); $result['lines'] = array_merge($result['lines'], $list); } else { $result['lines'][] = $int; } } flush(); } } $exit = get_exit_code($h); if ($exit !== 0) { $errors = get_all_data($h, array('stdout', 'stderr')); if (!is_array($errors)) { $errors = array(); } return error("command failed with exitcode " . $exit . ":\n" . implode(' ', $errors)); } $result['output'] = get_all_data($h); $result['outputhash'] = sha1($result['output']); $result['disable_commit'] = false; make_one_hash($result); } clean_up($h); return $result; }
$logfiles = scandir($logdir); foreach ($logfiles as $logfile) { if (strpos($logfile, 'access_log.') === 0) { echo date('H:i:s', time()) . " reading $logdir$logfile\n"; // log files on mobi and mobi-stage are gzipped if (strpos($logfile, 'gz') > 0) { $log = gzopen($logdir . $logfile, 'r'); while (!gzeof($log)) { parse_line(gzgets($log, 1024)); } gzclose($log); } else { // log files on mobi2 are not gzipped $log = fopen($logdir . $logfile, 'r'); while (!feof($log)) { parse_line(fgets($log, 1024)); } fclose($log); } } } function parse_line($line) { // ignore nagios checks and localhost calls if (strpos($line, '127.' === 0) || strpos($line, 'check_http') !== FALSE) return; if (preg_match('/GET ' . str_replace('/', '\/', HTTPROOT) . '([\w\-]+)\/?( HTTP|[\w\-]+\.php)/', $line, $matches)) { $module = $matches[1]; if ($module == 'home' || array_key_exists($module, Modules::full_list())) { preg_match('/\[(\d+\/\w+\/\d{4})/', $line, $matches); $day = strtotime(str_replace('/', '-', $matches[1]));
function place_cells($type, $begin, $end, $increment, $maxchar, $numrows, $cellwidth) { global $dbh, $db_functions, $tree_prefix_quoted, $pdf, $data_array, $posy, $posx, $marr_date_array, $marr_place_array, $sexe, $gedcomnumber; $pdf->SetLeftMargin(16); $marg = 16; for ($m = $begin; $m <= $end; $m += $increment) { if ($type == "pers") { // person's name & details data_array($m, $maxchar, $numrows); $pdf->SetFont('Arial', 'B', 8); if ($m % 2 == 0 or $m == 1 and $sexe[$m] == "M") { // male $pdf->SetFillColor(191, 239, 255); } else { // female $pdf->SetFillColor(255, 228, 225); } $pdf->MultiCell($cellwidth, 4, $data_array[$m][0], "LTR", "C", true); $marg += $cellwidth; $pdf->SetFont('Arial', '', 8); $nstring = ''; $used = $data_array[$m][3] + $data_array[$m][4] + $data_array[$m][5]; } else { // marr date & place $space = ''; if ($marr_date_array[$m] != '') { $space = ' '; } if ($gedcomnumber[$m] != '') { @($personDb = $db_functions->get_person($gedcomnumber[$m])); $person_cls = new person_cls(); $person_cls->construct($personDb); $pers_privacy = $person_cls->privacy; } else { $pers_privacy = false; } if ($gedcomnumber[$m + 1] != '') { @($womanDb = $db_functions->get_person($gedcomnumber[$m + 1])); $woman_cls = new person_cls(); $woman_cls->construct($womanDb); $woman_privacy = $person_cls->privacy; } else { $woman_privacy = false; } if ($pers_privacy or $woman_privacy) { $marr = __('PRIVACY FILTER'); } else { $marr = __('X') . ' ' . $marr_date_array[$m] . $space . $marr_place_array[$m]; } $result = parse_line($marr, $maxchar, $numrows); $marg += $cellwidth; $nstring = ''; $used = $result[0]; } for ($x = 1; $x <= $numrows - $used; $x++) { $nstring .= "\n" . " "; } if ($type == "pers") { $breakln = ''; if ($data_array[$m][1] != '' and $data_array[$m][2] != '') { $breakln = "\n"; } if ($data_array[$m][4] == 0 and $data_array[$m][5] == 0) { $nstring = substr($nstring, 0, strlen($nstring) - 1); } $pdf->SetFont('Arial', '', 8); $pdf->MultiCell($cellwidth, 4, $data_array[$m][1] . $breakln . $data_array[$m][2] . $nstring, "LRB", "C", true); } else { $pdf->SetFont('Arial', 'I', 8); $pdf->MultiCell($cellwidth, 4, $result[1] . $nstring, "LR", "C", false); } if ($m < $end) { $pdf->SetLeftMargin($marg); $pdf->SetY($posy); } } $pdf->SetX($posx); $posy = $pdf->GetY(); }
# open the input file $infile = fopen($file, 'r'); if (!$infile) { die("can't open {$file}\n"); } $line_count = 0; $change_count = 0; # read the file and process while (!feof($infile)) { $line = fgets($infile, 4096); if (trim($line) == '') { continue; } $line_count++; echo "working on line {$line_count}\n"; $data = parse_line($line); # print_r($data); if (!isset($data['page_name']) || $data['page_name'] == '') { continue; } # get the templates $page_template_text = get_wiki_text($data['page_template'], NS_TEMPLATE); $table_template_text = get_wiki_text($data['table_template'], NS_TEMPLATE); if ($table_template_text == '' || $page_template_text == '') { $err_msg = "ERROR: Something is missing..."; if ($page_template_text == '') { $err_msg .= "\n\tpage template empty or not found\n"; } if ($table_template_text == '') { $err_msg .= "\n\t table template empty or not found\n"; }
function commit_file_to_db($file, $room_name) { $f = fopen($file, 'r'); $room_id = get_room_id($room_name); $header = fgets($f); $con = connect_db(); $con->query("DELETE FROM meetings WHERE F_Id='$room_id'"); if (!($stmt = $con->prepare("INSERT INTO meetings (subject, start_datetime, end_datetime, F_Id) VALUES (?, ?, ?, ?)"))) { echo 'Prepare failed: ' . $con->errno . ' - ' . $con->error; exit; } if (!($stmt->bind_param('sssi', $subject, $start_datetime, $end_datetime, $room_id))) { echo 'BindParam failed: ' . $stmt->errno . ' - ' . $stmt->error; exit; } while ($line = fgets($f)) { $data = parse_line($line); if ($data) { extract($data); // See parse_line() for extracted values if (strlen($subject) > 1) { if (strpos($subject, 'Copy: ') === 0 || strpos($subject, 'Kopi: ') === 0) $subject = substr($subject, 6); $subject = utf8_encode($subject); if (!($stmt->execute())) { echo 'Execute() failed: ' . $stmt->errno . ' - ' . $stmt->error . '<br>'; exit; } } } } return true; }