Example #1
0
function GetConfigMaxIntKey(&$cfg_file)
{
    $high_num = 0;
    foreach ($cfg_file as $cfg_line) {
        $cfg_line = RTrim($cfg_line);
        //Only check lines that are not blank.
        if (!$cfg_line) {
            // Blank line
            continue;
        } elseif (Preg_Match("/^(\\/\\/|#)/", $cfg_line)) {
            //Comment lines
            continue;
        } elseif (Preg_Match("/^[[:alnum:]]+\\s+{$elem_name}/i", $cfg_line)) {
            //An elem key was found.
            //Remove the first word from the line and check if it is an Integer
            //type element. If so, tuck it into an array.
            $cfg_line = Preg_Replace("/^[[:alnum:]]+\\s+/", "", $cfg_line);
            if (Is_Numeric($cfg_line) ? IntVal($cfg_line) == $cfg_line : false) {
                if ($cfg_line > $high_num) {
                    $high_num = IntVal($cfg_line);
                }
            }
        }
    }
    return $high_num;
}
        function form($instance)
        {
            $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
            $flickr_username = isset($instance['flickr_username']) ? esc_attr($instance['flickr_username']) : '';
            $show_image = isset($instance['show_image']) && Is_Numeric($instance['show_image']) ? absint($instance['show_image']) : 8;
            ?>
		<p><label for="<?php 
            echo $this->get_field_id('title');
            ?>
"><?php 
            _e('Title:', 'rt_theme_admin');
            ?>
</label>
		<input class="widefat" id="<?php 
            echo $this->get_field_id('title');
            ?>
" name="<?php 
            echo $this->get_field_name('title');
            ?>
" type="text" value="<?php 
            echo $title;
            ?>
" /></p>
	
		<p><label for="<?php 
            echo $this->get_field_id('flickr_username');
            ?>
"><?php 
            _e('Flickr Username:'******'rt_theme_admin');
            ?>
</label>
		<input class="widefat" id="<?php 
            echo $this->get_field_id('flickr_username');
            ?>
" name="<?php 
            echo $this->get_field_name('flickr_username');
            ?>
" type="text" value="<?php 
            echo $flickr_username;
            ?>
" /></p>
	
		<p><label for="<?php 
            echo $this->get_field_id('show_image');
            ?>
"><?php 
            _e('Number of Photo to Display:', 'rt_theme_admin');
            ?>
</label>
		<input class="widefat" id="<?php 
            echo $this->get_field_id('show_image');
            ?>
" name="<?php 
            echo $this->get_field_name('show_image');
            ?>
" type="text" value="<?php 
            echo empty($show_image) ? 4 : $show_image;
            ?>
" /></p>
		
<?php 
        }
Example #3
0
function freshports_PortDisplay($db, $category, $port)
{
    global $TableWidth;
    global $FreshPortsTitle;
    global $User;
    require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/port-display.php';
    # these two options must be the last on the line.  And as such are mutually exclusive
    define('BYPASSCACHE', 'bypasscache=1');
    # do not read the cache for display
    define('REFRESHCACHE', 'refreshcache=1');
    # refresh the cache
    $BypassCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(BYPASSCACHE)) == BYPASSCACHE;
    $RefreshCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(REFRESHCACHE)) == REFRESHCACHE;
    $Debug = 0;
    if ($Debug) {
        echo 'into ' . __FILE__ . ' now' . "<br>\n";
    }
    $PageNumber = 1;
    if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
        parse_str($_SERVER['REDIRECT_QUERY_STRING'], $query_parts);
    } else {
        $query_parts = null;
    }
    if ($Debug) {
        echo print_r($query_parts, true);
    }
    if (isset($query_parts['page']) && Is_Numeric($query_parts['page'])) {
        $PageNumber = intval($query_parts['page']);
        if ($PageNumber != $query_parts['page'] || $PageNumber < 1) {
            $PageNumber = 1;
        }
    }
    $port_display = new port_display($db, $User);
    $port_display->SetDetailsFull();
    $Cache = new CachePort();
    $Cache->PageSize = $User->page_size;
    $result = $Cache->RetrievePort($category, $port, CACHE_PORT_DETAIL, $PageNumber);
    if (!$result && !$BypassCache && !$RefreshCache) {
        if ($Debug) {
            echo "found something from the cache<br>\n";
        }
        $HTML = $Cache->CacheDataGet();
        #
        # we need to know the element_id of this port
        # and the whether or not it is on the person's watch list
        # let's create a special function for that!
        #
        $EndOfFirstLine = strpos($HTML, "\n");
        if ($EndOfFirstLine == false) {
            die('Internal error: I was expecting an ElementID and found nothing');
        }
        # extract the ElementID from the cache
        $ElementID = intval(substr($HTML, 0, $EndOfFirstLine));
        if ($ElementID == 0) {
            syslog(LOG_ERR, "Extract of ElementID from cache failed.  Is cache corrupt/deprecated? port was {$category}/{$port}");
            die('sorry, I encountered a problem with the cache.  Please send the URL and this message to the webmaster.');
        }
        if ($User->id) {
            $OnWatchList = freshports_OnWatchList($db, $User->id, $ElementID);
        } else {
            $OnWatchList = 0;
        }
        $HTML = substr($HTML, $EndOfFirstLine + 1);
    } else {
        if ($Debug) {
            echo "found NOTHING in cache for '{$category}/{$port}'<br>\n";
        }
        $HTML = '';
        $port_id = freshports_GetPortID($db, $category, $port);
        if (!isset($port_id)) {
            if ($Debug) {
                echo "{$category}/{$port} is not a port according to freshports_GetPortID<br>\n";
            }
            return -1;
        }
        if ($Debug) {
            echo "{$category}/{$port} found by freshports_GetPortID<br>";
        }
        $MyPort = new Port($db);
        $MyPort->FetchByID($port_id, $User->id);
        $port_display->port = $MyPort;
        $HTML .= $port_display->Display();
        $HTML .= "</TD></TR>\n</TABLE>\n\n";
        $HTML .= DisplayPortCommits($MyPort, $PageNumber);
        # If we are not reading
        if (!$BypassCache || $RefreshCache) {
            $Cache->CacheDataSet($MyPort->{'element_id'} . "\n" . $HTML);
            $Cache->AddPort($MyPort->category, $MyPort->port, CACHE_PORT_DETAIL, $PageNumber);
        }
        $ElementID = $MyPort->{'element_id'};
        $OnWatchList = $MyPort->{'onwatchlist'};
    }
    # At this point, we have the port detail HTML
    $HTML = $port_display->ReplaceWatchListToken($OnWatchList, $HTML, $ElementID);
    global $ShowAds, $BannerAd;
    global $ShowAds;
    global $BannerAd;
    if ($ShowAds && $BannerAd) {
        $HTML_For_Ad = "<hr><center>\n" . Ad_728x90PortDescription() . "\n</center>\n<hr>\n";
    } else {
        $HTML_For_Ad = '';
    }
    $HTML = $port_display->ReplaceAdvertismentToken($HTML, $HTML_For_Ad);
    freshports_ConditionalGetUnix($Cache->LastModifiedGet());
    header("HTTP/1.1 200 OK");
    $Title = $category . "/" . $port;
    require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php';
    freshports_Start($Title, "{$FreshPortsTitle} - new ports, applications", "FreeBSD, index, applications, ports");
    ?>


<?php 
    echo freshports_MainTable();
    ?>

<tr><TD VALIGN="top" width="100%">

<?php 
    echo freshports_MainContentTable();
    ?>

<TR>
<?php 
    echo freshports_PageBannerText("Port details");
    ?>
</TR>

<tr><td valign="top" width="100%">

<?php 
    echo $HTML;
    ?>

</TD>
  <TD VALIGN="top" WIDTH="*" ALIGN="center">
  <?php 
    echo freshports_SideBar();
    ?>
  </td>
</TR>

</TABLE>

<?php 
    echo freshports_ShowFooter();
    ?>

</body>
</html>

<?php 
    return 0;
}
     $sql_method = $sql;
 } else {
     $sql = $sql_method;
     $sql .= 'Epic_Rank="' . $data[1] . '", ' . 'Iteration_Rank="' . $data[2] . '", ';
     $sql .= 'Release_ID="' . $release_id[$data[4]] . '", ';
     if (isset($iter_id[$data[5]])) {
         $sql .= 'Iteration_ID="' . $iter_id[$data[5]] . '", ';
     } else {
         $sql .= 'Iteration_ID="' . $iter_id['Backlog'] . '", ';
     }
     if (isset($user_id[$data[6]])) {
         $sql .= 'Owner_ID="' . $user_id[$data[6]] . '", ';
     } else {
         $sql .= 'Owner_ID="", ';
     }
     if (Is_Numeric($data[3])) {
         // we have a parent
         if ($data[0] + 0 == 0) {
             $sql .= ' Parent_Story_ID="0", ';
             // ignore for a new record
         } else {
             $sql .= ' Parent_Story_ID=( select s from (select AID s from story where ID=' . $data[3] . ' and Project_ID=' . $_REQUEST['PID'] . ') as s2 ), ';
         }
     } else {
         $sql .= ' Parent_Story_ID="", ';
     }
     $sql .= 'Type="' . $data[7] . '", ' . 'Project_ID="' . $_REQUEST['PID'] . '", ' . 'Status="' . trim($data[8]) . '", ' . 'Size="' . $data[9] . '", ' . 'Blocked="' . $data[10] . '", ' . 'Summary="' . htmlentities($data[11], ENT_QUOTES) . '", ' . 'Col_1="' . htmlentities($data[12], ENT_QUOTES) . '", ' . 'As_A="' . htmlentities($data[13], ENT_QUOTES) . '", ' . 'Col_2="' . htmlentities($data[14], ENT_QUOTES) . '", ' . 'Acceptance="' . htmlentities($data[15], ENT_QUOTES) . '", ' . 'Tags="' . $data[16] . '"';
 }
 $sql .= $whereClause;
 mysqli_query($DBConn, $sql);
 if (mysqli_error($DBConn)) {
function freshports_NonPortDescription($db, $element_record)
{
    global $TableWidth;
    global $FreshPortsTitle;
    $Debug = 1;
    freshports_ConditionalGet(freshports_LastModified());
    header("HTTP/1.1 200 OK");
    $Title = preg_replace('|^/?ports/|', '', $element_record->element_pathname);
    $FileName = preg_replace('|^/?ports/|', '', $element_record->element_pathname);
    require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php';
    freshports_Start($Title, "{$FreshPortsTitle} - new ports, applications", "FreeBSD, index, applications, ports");
    ?>

	<?php 
    echo freshports_MainTable();
    ?>

	<tr><td valign="top" width="100%">

	<?php 
    echo freshports_MainContentTable();
    ?>
<TR>
<?php 
    echo freshports_PageBannerText('non port: ' . $Title);
    ?>
</TR>
<tr><td>
<a HREF="<?php 
    echo FRESHPORTS_FREEBSD_SVN_URL . $element_record->element_pathname;
    ?>
?view=log">SVNWeb</a>
</td></tr>

<?php 
    global $User;
    # these two options must be the last on the line.  And as such are mutually exclusive
    define('BYPASSCACHE', 'bypasscache=1');
    # do not read the cache for display
    define('REFRESHCACHE', 'refreshcache=1');
    # refresh the cache
    $BypassCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(BYPASSCACHE)) == BYPASSCACHE;
    $RefreshCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(REFRESHCACHE)) == REFRESHCACHE;
    $PageNumber = 1;
    if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
        parse_str($_SERVER['REDIRECT_QUERY_STRING'], $query_parts);
        if (isset($query_parts['page']) && Is_Numeric($query_parts['page'])) {
            $PageNumber = intval($query_parts['page']);
            if ($PageNumber != $query_parts['page'] || $PageNumber < 1) {
                $PageNumber = 1;
            }
        }
    }
    $NumCommitsPerPage = $User->page_size;
    $Cache = new CacheFile();
    $Cache->PageSize = $User->page_size;
    $result = $Cache->Retrieve($FileName, $PageNumber);
    if (!$result && !$BypassCache && !$RefreshCache) {
        if ($Debug) {
            echo "found something from the cache<br>\n";
        }
        $HTML = $Cache->CacheDataGet();
        #
        # we need to know the element_id of this port
        # and the whether or not it is on the person's watch list
        # let's create a special function for that!
        #
        $EndOfFirstLine = strpos($HTML, "\n");
        if ($EndOfFirstLine == false) {
            die('Internal error: I was expecting an ElementID and found nothing');
        }
        # extract the ElementID from the cache
        $ElementID = intval(substr($HTML, 0, $EndOfFirstLine));
        if ($ElementID == 0) {
            syslog(LOG_ERR, "Extract of ElementID from cache failed.  Is cache corrupt/deprecated? port was {$category}/{$port}");
            die('sorry, I encountered a problem with the cache.  Please send the URL and this message to the webmaster.');
        }
        if ($User->id) {
            $OnWatchList = freshports_OnWatchList($db, $User->id, $ElementID);
        } else {
            $OnWatchList = 0;
        }
        $HTML = substr($HTML, $EndOfFirstLine + 1);
    } else {
        if ($Debug) {
            echo "found NOTHING in cache<br>\n";
        }
        $HTML = '';
        $Commits = new CommitsByTreeLocation($db);
        $Commits->SetLimit($Cache->PageSize);
        $Commits->Debug = $Debug;
        $Commits->UserIDSet($User->id);
        $Commits->TreePathConditionSet("= '" . $element_record->element_pathname . "'");
        #
        # get the count without excuting the whole query
        # we don't want to pull back all the data.
        #
        $NumCommits = $Commits->GetCountCommits();
        $params = array('mode' => 'Sliding', 'perPage' => $NumCommitsPerPage, 'delta' => 5, 'totalItems' => $NumCommits, 'urlVar' => 'page', 'currentPage' => $PageNumber, 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, 'append' => false, 'path' => '/' . preg_replace('|^/?ports/|', '', $element_record->element_pathname), 'fileName' => '?page=%d', 'altFirst' => 'First Page', 'firstPageText' => 'First Page', 'altLast' => 'Last Page', 'lastPageText' => 'Last Page');
        $Pager =& Pager::factory($params);
        $links = $Pager->GetLinks();
        $NumCommitsHTML = '<tr><td><p align="left">Number of commits found: ' . $NumCommits;
        $Offset = 0;
        $PageLinks = $links['all'];
        $PageLinksHTML = str_replace('/?page=1"', '"', $PageLinks);
        $PageLinksHTML = str_replace('/?page=', '?page=', $PageLinksHTML);
        if ($PageLinksHTML != '') {
            $offset = $Pager->getOffsetByPageId();
            $NumOnThisPage = $offset[1] - $offset[0] + 1;
            $Offset = $offset[0] - 1;
            $NumCommitsHTML .= " (showing only {$NumOnThisPage} on this page)";
            unset($offset);
        }
        if ($PageNumber > 1) {
            $Commits->SetOffset($Offset);
        }
        $NumCommitsHTML .= '</p>';
        if ($PageLinksHTML != '') {
            $PageLinksHTML = '<p align="center">' . $PageLinksHTML . '</p>';
        }
        $NumCommitsHTML .= $PageLinksHTML . '</td></tr>';
        $HTML = $NumCommitsHTML;
        if ($Commits->Debug) {
            echo "PageNumber='{$PageNumber}'<br>Offset='{$Offset}'<br>";
        }
        $NumFetches = $Commits->Fetch();
        $DisplayCommit = new DisplayCommit($db, $Commits->LocalResult);
        $HTML .= $DisplayCommit->CreateHTML();
        $HTML .= $NumCommitsHTML;
        # If we are not reading
        if (!$BypassCache || $RefreshCache) {
            $Cache->CacheDataSet($element_record->{'id'} . "\n" . $HTML);
            $Cache->Add($FileName, $PageNumber);
        }
    }
    echo $HTML;
    echo "</table>\n";
    ?>

</TD>
  <TD VALIGN="top" WIDTH="*" ALIGN="center">
  <?php 
    echo freshports_SideBar();
    ?>
  </td>
</TR>

</TABLE>

<?php 
    echo freshports_ShowFooter();
    ?>

</body>
</html>

<?php 
}
Example #6
0
    $dailysummary = pg_escape_string($_REQUEST["dailysummary"]);
}
if (isset($_REQUEST['days'])) {
    $days = pg_escape_string($_REQUEST["days"]);
}
if (Is_Numeric($num)) {
    $MaxNumberOfPortsLong = min($MaxNumberOfPortsLong, max(10, $num));
} else {
    $num = MaxNumberOfPortsLong;
}
if (Is_Numeric($days)) {
    $NumberOfDays = min($NumberOfDays, max(0, $days));
} else {
    $days = $NumberOfDays;
}
if (Is_Numeric($dailysummary)) {
    $dailysummary = min($NumberOfDays, max(0, $dailysummary));
} else {
    unset($dailysummary);
}
if ($db) {
    ?>
<TR><TD VALIGN="top" WIDTH="100%">

<?php 
    echo freshports_MainContentTable();
    ?>

<TR>
<?php 
    echo freshports_PageBannerText("{$MaxNumberOfPortsLong} most recent commits", 3);