Пример #1
0
function debug_footer($db)
{
    if ($_SESSION['debug'] > 0) {
        debug_output();
        debug(1);
        echo "\n";
        echo "###### System info ######\n";
        echo file_get_contents('/proc/version');
        echo "\n";
        echo "system load:\t" . file_get_contents('/proc/loadavg');
        echo "\n";
        echo "HW platform:\t" . $_SESSION['hwplatform'] . " (" . $_SESSION['hwplatformid'] . ")\n";
        echo "\n";
        echo "playerID:\t" . $_SESSION['playerid'] . "\n";
        echo "\n";
        echo "\n";
        echo "###### Audio backend ######\n";
        echo file_get_contents('/proc/asound/version');
        echo "\n";
        echo "Card list: (/proc/asound/cards)\n";
        echo "--------------------------------------------------\n";
        echo file_get_contents('/proc/asound/cards');
        echo "\n";
        echo "ALSA interface #0: (/proc/asound/card0/pcm0p/info)\n";
        echo "--------------------------------------------------\n";
        echo file_get_contents('/proc/asound/card0/pcm0p/info');
        echo "\n";
        echo "ALSA interface #1: (/proc/asound/card1/pcm0p/info)\n";
        echo "--------------------------------------------------\n";
        echo file_get_contents('/proc/asound/card1/pcm0p/info');
        echo "\n";
        echo "interface #0 stream status: (/proc/asound/card0/stream0)\n";
        echo "--------------------------------------------------------\n";
        $streaminfo = file_get_contents('/proc/asound/card0/stream0');
        if (empty($streaminfo)) {
            echo "no stream present\n";
        } else {
            echo $streaminfo;
        }
        echo "\n";
        echo "interface #1 stream status: (/proc/asound/card1/stream0)\n";
        echo "--------------------------------------------------------\n";
        $streaminfo = file_get_contents('/proc/asound/card1/stream0');
        if (empty($streaminfo)) {
            echo "no stream present\n";
        } else {
            echo $streaminfo;
        }
        echo "\n";
        echo "\n";
        echo "###### Kernel optimization parameters ######\n";
        echo "\n";
        echo "hardware platform:\t" . $_SESSION['hwplatform'] . "\n";
        echo "current orionprofile:\t" . $_SESSION['orionprofile'] . "\n";
        echo "\n";
        // 		echo  "kernel scheduler for mmcblk0:\t\t".((empty(file_get_contents('/sys/block/mmcblk0/queue/scheduler'))) ? "\n" : file_get_contents('/sys/block/mmcblk0/queue/scheduler'));
        echo "kernel scheduler for mmcblk0:\t\t" . file_get_contents('/sys/block/mmcblk0/queue/scheduler');
        echo "/proc/sys/vm/swappiness:\t\t" . file_get_contents('/proc/sys/vm/swappiness');
        echo "/proc/sys/kernel/sched_latency_ns:\t" . file_get_contents('/proc/sys/kernel/sched_latency_ns');
        echo "/proc/sys/kernel/sched_rt_period_us:\t" . file_get_contents('/proc/sys/kernel/sched_rt_period_us');
        echo "/proc/sys/kernel/sched_rt_runtime_us:\t" . file_get_contents('/proc/sys/kernel/sched_rt_runtime_us');
        echo "\n";
        echo "\n";
        echo "###### Filesystem mounts ######\n";
        echo "\n";
        echo file_get_contents('/proc/mounts');
        echo "\n";
        echo "\n";
        echo "###### mpd.conf ######\n";
        echo "\n";
        echo file_get_contents('/etc/mpd.conf');
        echo "\n";
    }
    if ($_SESSION['debug'] > 1) {
        echo "\n";
        echo "\n";
        echo "###### PHP backend ######\n";
        echo "\n";
        echo "php version:\t" . phpVer() . "\n";
        echo "debug level:\t" . $_SESSION['debug'] . "\n";
        echo "\n";
        echo "\n";
        echo "###### SESSION ######\n";
        echo "\n";
        echo "STATUS:\t\t" . session_status() . "\n";
        echo "ID:\t\t" . session_id() . "\n";
        echo "SAVE PATH:\t" . session_save_path() . "\n";
        echo "\n";
        echo "\n";
        echo "###### SESSION DATA ######\n";
        echo "\n";
        print_r($_SESSION);
    }
    if ($_SESSION['debug'] > 2) {
        $connection = new pdo($db);
        $querystr = "SELECT * FROM cfg_engine";
        $data['cfg_engine'] = sdbquery($querystr, $connection);
        $querystr = "SELECT * FROM cfg_lan";
        $data['cfg_lan'] = sdbquery($querystr, $connection);
        $querystr = "SELECT * FROM cfg_wifisec";
        $data['cfg_wifisec'] = sdbquery($querystr, $connection);
        $querystr = "SELECT * FROM cfg_mpd";
        $data['cfg_mpd'] = sdbquery($querystr, $connection);
        $querystr = "SELECT * FROM cfg_source";
        $data['cfg_source'] = sdbquery($querystr, $connection);
        $connection = null;
        echo "\n";
        echo "\n";
        echo "###### SQLite datastore ######\n";
        echo "\n";
        echo "\n";
        echo "### table CFG_ENGINE ###\n";
        print_r($data['cfg_engine']);
        echo "\n";
        echo "\n";
        echo "### table CFG_LAN ###\n";
        print_r($data['cfg_lan']);
        echo "\n";
        echo "\n";
        echo "### table CFG_WIFISEC ###\n";
        print_r($data['cfg_wifisec']);
        echo "\n";
        echo "\n";
        echo "### table CFG_SOURCE ###\n";
        print_r($data['cfg_source']);
        echo "\n";
        echo "\n";
        echo "### table CFG_MPD ###\n";
        print_r($data['cfg_mpd']);
        echo "\n";
    }
    if ($_SESSION['debug'] > 0) {
        echo "\n";
        printf("Page created in %.5f seconds.", microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']);
        echo "\n";
        echo "\n";
    }
}
Пример #2
0
                if ($err != 0) {
                    $errorcount++;
                }
                // delete old molcfp record first
                $qstr = "DELETE FROM {$molcfptable} WHERE mol_id = {$item_id}";
                $result = mysql_query($qstr);
                $err = mysql_errno();
                if ($err != 0) {
                    $errorcount++;
                }
            }
        }
        echo "<h3>Done.</h3>\n";
    }
    if ($debug > 0) {
        debug_output("Action finished with {$errorcount} errors.<br />\n");
    }
    $errorcount = 0;
    echo "<p /><a href=\"{$myname}?db={$db_id}\">Continue</a>\n";
    echo "</body></html>\n";
    die;
}
function mk_inputline($iname, $idefault)
{
    echo "<input type=\"text\" name=\"{$iname}\" size=\"106\" value=\"{$idefault}\">";
}
function mk_inputarea($iname, $idefault)
{
    echo "<textarea name=\"{$iname}\" cols=\"80\" rows=\"4\">{$idefault}</textarea>\n";
}
function mk_inputselect($iname, $itype, $idefault)
Пример #3
0
    if ($participant_id) {
        participants__get_statistics($participant_id);
    }
    if ($settings['enable_email_module'] == 'y' && isset($_REQUEST['participant_id'])) {
        $nums = email__get_privileges('participant', $_REQUEST, 'read', true);
        if ($nums['allowed'] && $nums['num_all'] > 0) {
            echo '<br><br><TABLE class="or_page_subtitle" style="background: ' . $color['page_subtitle_background'] . '; color: ' . $color['page_subtitle_textcolor'] . '; width: 90%">
					<TR><TD align="left">
						' . lang('emails') . '
					</TD></TR></TABLE>';
            echo javascript__email_popup();
            $url_string = 'participant_id=' . $participant_id;
            if ($hide_header) {
                $url_string .= '&hide_header=true';
            }
            email__list_emails('participant', $_REQUEST['participant_id'], $nums['rmode'], $url_string, false);
        }
    }
    echo "</CENTER>";
}
if ($hide_header) {
    echo '<BR><BR><BR><BR>';
    debug_output();
    echo '</TD></TR><TABLE></center><BR>';
    html__footer();
} else {
    include "footer.php";
}
if ($hide_header) {
    echo str_ireplace("href=", "target=\"_parent\" href=", ob_get_clean());
}
Пример #4
0
 //echo "inner qstr: $qstr_i<br>";
 $result3 = mysql_query($qstr_i) or die("Query failed! (4a_inner)");
 while ($line3 = mysql_fetch_array($result3, MYSQL_ASSOC)) {
     $total_cand++;
     $rxn_id_i = $line3["rxn_id"];
     //echo "inner loop candidate: $rxn_id_i<br>\n";
     $qstr_struc = "SELECT struc, map FROM {$rxnstructable} WHERE rxn_id = {$rxn_id}";
     $result2 = mysql_query($qstr_struc) or die("Query failed! (4a_struc)");
     $line2 = mysql_fetch_row($result2);
     $struc = $line2[0];
     $struc = str_replace("\n", "\r\n", $struc);
     $struc = str_replace("\r\r\n", "\r\n", $struc);
     $map = $line2[1];
     //echo "<pre>$struc</pre>";
     if ($debug > 2) {
         debug_output("***** match protocol for candidate {$db_id}:{$rxn_id}\n");
     }
     $total_cand_sum++;
     $strucmatch = matchrxn($saferxn, $struc, $map, $options);
     if ($strucmatch == TRUE) {
         $hits++;
         $hits_sum++;
         if ($hits_sum > $maxhits) {
             echo "</table>\n";
             echo "<hr>There are more hits....<br>\n";
             $hits_sum--;
             $total_cand_sum--;
             mk_continueform($db_id, $rxn_id, $nhits, $hitlist);
             $pageonly = " on this page";
             $endpage = false;
             break 4;
Пример #5
0
function get_svgmode()
{
    global $debug;
    $dummy = getagent();
    $ua_name = $dummy["name"];
    $ua_ver = $dummy["version"];
    #echo "more specifically: $ua_name, version $ua_ver<br>\n";
    if ($debug > 0) {
        debug_output("browser: {$ua_name}, version {$ua_ver}");
    }
    $svgmode = 0;
    // default: SVG not supported
    if ($ua_name === "MSIE" && $ua_ver >= 9) {
        $svgmode = 1;
    }
    if ($ua_name === "Firefox" && $ua_ver >= 4) {
        $svgmode = 1;
    }
    if ($ua_name === "Chrome" && $ua_ver >= 7) {
        $svgmode = 1;
    }
    if ($ua_name === "Opera" && $ua_ver >= 8) {
        $svgmode = 2;
    }
    // ?? inline SVG since 11.6
    if ($ua_name === "Opera" && $ua_ver >= 11.6) {
        $svgmode = 1;
    }
    // ?? inline SVG since 11.6
    if ($ua_name === "Safari" && $ua_ver >= 500) {
        $svgmode = 2;
    }
    // ?? inline SVG since 5.1
    if ($ua_name === "Safari" && $ua_ver >= 510) {
        $svgmode = 1;
    }
    // ?? inline SVG since 5.1
    // currently, display of _scaled_ external SVGs does not work properly, so disable mode 2
    if ($svgmode == 2) {
        $svgmode = 0;
    }
    return $svgmode;
}
Пример #6
0
function GroupCalendarParse($lua_data, $only_realm = "")
{
    global $debuging_flag;
    $calendar_items = array();
    $count = 0;
    if (!array_key_exists("gGroupCalendar_Database", $lua_data)) {
        if ($debuging_flag) {
            debug_output("\n\nERROR:  No Calendar Database key found in LUA Data.\n\n");
        }
        return array();
    }
    $database = $lua_data['gGroupCalendar_Database'];
    if ($debuging_flag) {
        debug_output("Database Format is " . $database['Format'] . "\n");
    }
    if ($debuging_flag && $database['Format'] != 14) {
        debug_output("WARNING: Expecting Format 14, possible errors from different format versions.  Continuing anyway...\n");
    }
    $gd = $database['Databases'];
    foreach (array_keys($gd) as $char_name) {
        //get char name that posted the event
        $charName = $gd[$char_name]['UserName'];
        $realm = $gd[$char_name]['Realm'];
        if ($only_realm != "" && $realm != $only_realm) {
            if ($debuging_flag) {
                debug_output("Entry {$char_name} is being skipped because the realm '{$realm}' does not meet required realm of '{$only_realm}'.\n");
            }
            continue;
        }
        $events = $gd[$char_name]['Events'];
        if ($debuging_flag == 2) {
            debug_output("{$char_name} Events ");
            debug_output(print_r($events, 1));
        }
        foreach (array_keys($events) as $event) {
            if ($debuging_flag == 2) {
                debug_output("Event {$event}\n");
            }
            $detail = $events[$event];
            foreach (array_keys($detail) as $detailinfo) {
                $thisEvent = array();
                $detailedinfo = $detail[$detailinfo];
                if ($debuging_flag == 2) {
                    debug_output(print_r($detailedinfo, 1));
                }
                // the 'mPrivate' field will signify if this event is private and shouldn't be uploaded
                if ($detailedinfo['mPrivate'] == "true") {
                    continue;
                }
                $mDate = $detailedinfo['mDate'];
                $mTitle = $detailedinfo['mTitle'];
                $mType = $detailedinfo['mType'];
                $mID = $detailedinfo['mID'];
                $mTime = $detailedinfo['mTime'];
                $mGuildOnly = $detailedinfo['mGuild'];
                $mDescription = $detailedinfo['mDescription'];
                $mDuration = $detailedinfo['mDuration'];
                $mMinLevel = $detailedinfo['mMinLevel'];
                $mMaxLevel = $detailedinfo['mMaxLevel'];
                $mAttendance = $detailedinfo['mAttendance'];
                $mLimits = $detailedinfo['mLimits'];
                $mMaxAttendance = $detailedinfo['mLimits']['mMaxAttendance'];
                //Convert GroupCal Date to Calendar date
                $startdate = mktime(12, 0, 0, 1, 1, 2000);
                $mDateConv = $startdate + $mDate * 86400;
                $eventDate = getdate($mDateConv);
                //Convert GroupCal Time to Standard Time
                $eventTime = $mTime / 60;
                if ($decpos = strpos($eventTime, '.')) {
                    $eventTimeH = substr($eventTime, 0, $decpos);
                    $eventTimeM = substr($eventTime, $decpos);
                    $eventTimeM = 60 * $eventTimeM;
                    $eventTimeS = 0;
                    if ($eventTimeM > 0 && $eventTimeM < 10) {
                        $eventTimeM = 05;
                    }
                } else {
                    $eventTimeH = $eventTime;
                    $eventTimeM = 0;
                    $eventTimeS = 0;
                }
                //Calculate Duration (leave it in minutes)
                $duration = (int) $mDuration;
                if ($debuging_flag == 2) {
                    print "Title: {$mTitle}<br />Date: {$mDate} Time: {$mTime}<br />\n";
                }
                if ($debuging_flag == 2) {
                    print "Initial Date found to be {$eventTimeH}:{$eventTimeM}:{$eventTimeS} " . $eventDate['mon'] . "/" . $eventDate['mday'] . "/" . $eventDate['year'] . "<br />\n";
                }
                //check event type for b-day and set time to be allday event
                if ($mType == 'Birth') {
                    $eventTimeS = 25;
                    $eventTimeH = 0;
                    $eventTimeM = 0;
                    $duration = 0;
                } else {
                    $eventTimeS = $eventTimeS - WOW_TIME_OFFSET * 3600;
                }
                //Not a birthday, so add the Server Time Offset to store it in GMT
                //Calculate the Unix Date using the vars we have gotten from our data.
                $date = mktime($eventTimeH, $eventTimeM, $eventTimeS, $eventDate['mon'], $eventDate['mday'], $eventDate['year']);
                if ($debuging_flag == 2) {
                    print "GMT Date found to be " . date("r", $date) . "<br />\n";
                }
                //Parse the attendace information.
                $fAttendance = "";
                if (is_array($mAttendance)) {
                    $fAttendance = array();
                    //Check for People whom will attend the event.
                    $attenCount = 0;
                    foreach (array_keys($mAttendance) as $attendees) {
                        $currAttend = explode(",", $mAttendance[$attendees]);
                        //$currAttend = array(modified date,modified time,status,playerinfo,attend_comment,guild,guild rank,create date,create time)
                        // playerinfo is string of 4 characters: first one is Race, second one is Class, last two are level
                        $fAttendance[$attenCount]['Name'] = $attendees;
                        $fAttendance[$attenCount]['str'] = $mAttendance[$attendees];
                        $fAttendance[$attenCount]['modDate'] = $currAttend[0];
                        $fAttendance[$attenCount]['modTime'] = $currAttend[1];
                        $fAttendance[$attenCount]['Status'] = $currAttend[2];
                        $fAttendance[$attenCount]['Level'] = substr($currAttend[3], 2, 2);
                        $fAttendance[$attenCount]['RaceCode'] = substr($currAttend[3], 0, 1);
                        $fAttendance[$attenCount]['ClassCode'] = substr($currAttend[3], 1, 1);
                        $fAttendance[$attenCount]['Comment'] = $currAttend[4];
                        $fAttendance[$attenCount]['Guild'] = $currAttend[5];
                        $fAttendance[$attenCount]['GuildRank'] = $currAttend[6];
                        $fAttendance[$attenCount]['createDate'] = $currAttend[7];
                        $fAttendance[$attenCount]['createTime'] = $currAttend[8];
                        //Convert GroupCal Time and Date to Gregorian Calendar date GMT timezone
                        //	Time is stored is seconds since midnight
                        $startdate = mktime(12, 0, 0, 1, 1, 2000);
                        if ($fAttendance[$attenCount]['modDate'] != "") {
                            $mDateConv = $startdate + $fAttendance[$attenCount]['modDate'] * 86400;
                            $modDate = getdate($mDateConv);
                            $eventTimeS = $fAttendance[$attenCount]['modTime'] % 60;
                            $eventTimeH = floor($fAttendance[$attenCount]['modTime'] / 60);
                            $eventTimeM = $eventTimeH % 60;
                            $eventTimeH = floor($eventTimeH / 60);
                            $modDate = mktime($eventTimeH, $eventTimeM, $eventTimeS, $modDate['mon'], $modDate['mday'], $modDate['year']);
                            $modDate = $modDate - WOW_TIME_OFFSET * 3600;
                            $fAttendance[$attenCount]['modDate'] = date("Y-m-d", $modDate);
                            $fAttendance[$attenCount]['modTime'] = date("H:i:s", $modDate);
                        }
                        if ($fAttendance[$attenCount]['createDate'] != "") {
                            $mDateConv = $startdate + $fAttendance[$attenCount]['createDate'] * 86400;
                            $modDate = getdate($mDateConv);
                            $eventTimeS = $fAttendance[$attenCount]['createTime'] % 60;
                            $eventTimeH = floor($fAttendance[$attenCount]['createTime'] / 60);
                            $eventTimeM = $eventTimeH % 60;
                            $eventTimeH = floor($eventTimeH / 60);
                            $modDate = mktime($eventTimeH, $eventTimeM, $eventTimeS, $modDate['mon'], $modDate['mday'], $modDate['year']);
                            $modDate = $modDate - WOW_TIME_OFFSET * 3600;
                            $fAttendance[$attenCount]['createDate'] = date("Y-m-d", $modDate);
                            $fAttendance[$attenCount]['createTime'] = date("H:i:s", $modDate);
                        }
                        //Increment and ready for next loop
                        $attenCount++;
                        if ($debuging_flag == 2) {
                            debug_output('<br>' . $name . ' ' . $status . ' ' . $level . ' ' . Race($raceCode) . ' ' . ClassInt($classCode) . ' ' . $guild);
                        }
                    }
                }
                $fAttendLimits = $mLimits['mClassLimits'];
                $thisEvent['Creator'] = $charName;
                $thisEvent['DateTime'] = $date;
                $thisEvent['Title'] = $mTitle;
                $thisEvent['Type'] = $mType;
                $thisEvent['ID'] = $mID;
                $thisEvent['description'] = $mDescription;
                $thisEvent['GuildOnly'] = $mGuildOnly;
                $thisEvent['Duration'] = $duration;
                $thisEvent['MinLevel'] = $mMinLevel;
                $thisEvent['MaxLevel'] = $mMaxLevel;
                $thisEvent['Attendance'] = $fAttendance;
                $thisEvent['Limits'] = $fAttendLimits;
                $thisEvent['MaxAttendance'] = $mMaxAttendance;
                $calendar_items[$charName . $mID] = $thisEvent;
            }
        }
    }
    return $calendar_items;
}
function EC2_DescribeVolumes($creds)
{
    $zabbix_name = $creds['zabbix_name'];
    $xml_object = exec_ec2_query($creds, 'DescribeVolumes');
    debug_output(__FILE__ . ':' . __FUNCTION__ . ':' . __LINE__ . ':' . "HTTP result received from EC2 for DescribeVolumes = " . var_export($xml_object, true));
    // Initialize counters
    $volume_status_array = array("creating" => array("Volumes_Status_creating" => 0, "Volumes_Status_creating_Total_Size_GB" => 0), "available" => array("Volumes_Status_available" => 0, "Volumes_Status_available_Total_Size_GB" => 0), "other" => array("Volumes_Status_other" => 0, "Volumes_Status_other_Total_Size_GB" => 0));
    $volume_attachment_status_array = array("attaching" => array("Volumes_attaching" => 0, "Volumes_attaching_Total_Size_GB" => 0), "attached" => array("Volumes_attached" => 0, "Volumes_attached_Total_Size_GB" => 0), "detaching" => array("Volumes_detaching" => 0, "Volumes_detaching_Total_Size_GB" => 0), "detached" => array("Volumes_detached" => 0, "Volumes_detached_Total_Size_GB" => 0));
    // A successful query to the EC2 API will have one or more
    // volumeSets - so iterate through that.
    // Each volumeSet in turn will have zero, one or more
    // items containing a volume with volumeId.
    foreach ($xml_object->volumeSet as $volumeSet) {
        if (empty($volumeSet)) {
            break;
        }
        foreach ($volumeSet->item as $volumeId) {
            $volume_status = $volumeId->status;
            $volume_size = $volumeId->size;
            switch ($volume_status) {
                case "creating":
                    break;
                case "available":
                    break;
                default:
                    $volume_status = "other";
                    break;
            }
            $volume_status_array["{$volume_status}"]["Volumes_Status_{$volume_status}"]++;
            $volume_status_array["{$volume_status}"]["Volumes_Status_{$volume_status}_Total_Size_GB"] += $volume_size;
            foreach ($volumeId->attachmentSet as $attachmentSet) {
                if (empty($volumeSet)) {
                    break;
                }
                $attachment_status = $attachmentSet->item->status;
                $volume_attachment_status_array["{$attachment_status}"]["Volumes_{$attachment_status}"]++;
                $volume_attachment_status_array["{$attachment_status}"]["total_{$attachment_status}_Total_Size_GB"] += $volume_size;
            }
        }
    }
    // Print all the data so that it can be sent to Zabbix
    foreach ($volume_status_array as $volume_status => $volume_status_data_array) {
        foreach ($volume_status_data_array as $key => $value) {
            write_to_data_file("{$zabbix_name} {$key} {$value}");
        }
    }
    foreach ($volume_attachment_status_array as $volume_attachment_status => $volume_attachment_status_data_array) {
        foreach ($volume_attachment_status_data_array as $key => $value) {
            write_to_data_file("{$zabbix_name} {$key} {$value}");
        }
    }
}
Пример #8
0
</head>
<body>
<div class="container">
  <div class="row">
    <div class="col-md-12 col-xm-12">
      <?php 
show_header($myname, $dbstr);
?>
    </div>
  </div>
</div>


<?php 
if ($debug > 0) {
    debug_output("MolDB6, OS type {$ostype}");
}
$mode = $defaultmode;
//show_header($myname,$dbstr);
$ndb = get_numdb_readable();
if ($ndb == 0) {
    echo "<h3>no data collection available</h3><br>\n</body>\n</html>\n";
    die;
}
echo "<h2><span style=\"color:Purple\">{$sitename}</span></h2>\n";
$jmemol = "";
if (strlen($mol) > 10) {
    $jmemol = tr4jme($mol);
}
//############################################################################################
$safemol = clean_molfile($mol);
Пример #9
0
/**
 * Calls a function for every file in a folder.
 *
 * @author Vasil Rangelov a.k.a. boen_robot
 *
 * @param string $callback The function to call. It must accept one argument that is a relative filepath of the file.
 * @param string $dir The directory to traverse.
 * @param array $types The file types to call the function for. Leave as NULL to match all types.
 * @param bool $recursive Whether to list subfolders as well.
 * @param string $baseDir String to append at the beginning of every filepath that the callback will receive.
 */
function dir_walk($callback, $dir, $types = null, $ignore = null, $recursive = false, $baseDir = '')
{
    $dir = rtrim($dir, '/');
    debug_output("opening directory " . $dir, 0);
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file === '.' || $file === '..') {
                continue;
            }
            $continue = true;
            if (isset($GLOBALS['ignore'])) {
                foreach ($GLOBALS['ignore'] as $regex) {
                    $test = preg_match($regex, $file);
                    if ($test && count($test)) {
                        debug_output('found "' . $regex . '" skipping file ' . $file, 1);
                        $continue = false;
                    } elseif (preg_last_error()) {
                        debug_output('Bad regex "' . $regex . '" preg_last_error = ' . preg_error_output(preg_last_error()), 5);
                    }
                }
            }
            if ($continue) {
                $file_path = $dir . '/' . $file;
                if (is_file($file_path)) {
                    debug_output('found file ' . $file_path, 0);
                    if (is_array($types)) {
                        $pathinfo = pathinfo($file_path, PATHINFO_EXTENSION);
                        debug_output($pathinfo, 0);
                        if (!in_array(strtolower($pathinfo), $types, true)) {
                            continue;
                        }
                    }
                    $callback($baseDir . $file);
                } elseif ($recursive && is_dir($file_path)) {
                    dir_walk($callback, $file_path . DIRECTORY_SEPARATOR, $types, $ignore, $recursive, $baseDir . $file . DIRECTORY_SEPARATOR);
                } else {
                    debug_output('doing nothing ' . $file_path);
                }
            }
        }
        closedir($dh);
    } else {
        echo "unable to open directory {$dir}\r\n";
    }
    debug_output("leaving directory " . $file, 0);
}
Пример #10
0
function matchmolrxn($qmol, $crxn, $options)
{
    global $use_cmmmsrv;
    global $ostype;
    global $mmcmd;
    global $debug;
    $result = TRUE;
    if (strlen($qmol) < 10 || strlen($crxn) < 20) {
        $result = FALSE;
    }
    if ($result == TRUE) {
        $result = FALSE;
        if ($use_cmmmsrv == "y") {
            $separator = "\$\$\$\$";
            $lf = "\n";
        } else {
            $separator = "\\\$\\\$\\\$\\\$";
            if ($ostype == 1) {
                $lf = "\n";
            }
            // Linux
            if ($ostype == 2) {
                $lf = "\r\n";
            }
            // Windows
        }
        $allmol = array();
        $allmol = explode("\$MOL\r\n", $crxn);
        $header = $allmol[0];
        $mol = array();
        $mol = array_slice($allmol, 1);
        $nmol = count($mol);
        if ($debug > 4) {
            debug_output("nmol: {$nmol}\n");
        }
        //============ now match
        if ($nmol > 0) {
            // assemble the SDF files to be passed to matchmol
            $qmol = rtrim($qmol);
            $sdf = $qmol . $lf . $separator . $lf;
            for ($ic = 0; $ic < $nmol; $ic++) {
                $cmol = rtrim($mol[$ic]);
                $sdf .= $cmol . $lf . $separator . $lf;
            }
            // end   for ($ic ...
            if ($debug > 4) {
                debug_output("{$sdf}\n");
            }
            if ($use_cmmmsrv == "y") {
                $matchresult = filterthroughcmmm("{$sdf}", "#### matchmol:{$options}");
            } else {
                if ($ostype == 1) {
                    $matchresult = filterthroughcmd("{$sdf} ", "{$mmcmd}");
                }
                if ($ostype == 2) {
                    $sdf = str_replace("\r", "", $sdf);
                    // for Windows
                    $sdf = str_replace("\n", "\r\n", $sdf);
                    // for Windows
                    $matchresult = filterthroughcmd2("{$sdf} ", "{$mmcmd}");
                }
            }
            //echo "<pre>match result:\n$matchresult\n</pre>";
            $br = explode("\n", $matchresult);
            $nr = count($br);
            for ($ir = 0; $ir < $nr; $ir++) {
                if (strpos($br[$ir], ":T") !== FALSE) {
                    $result = TRUE;
                }
            }
        }
        // end    if ($nmol > 0)
    }
    // end if ($result == TRUE) from initial check
    return $result;
}