Page 1 of 3

phpBB Code Repository

Posted: Fri Jul 03, 2009 5:36 am
by Extensions Robot
Modification name: phpBB Code Repository
Author: Desdenova
Modification description: A Code Repository MOD, it allows the viewing of source code/images in the source file directory, and also offers syntax highlighting of the source VIA GeSHi.
Modification version: 1.0.6
Tested on phpBB version: 3.0.5

Download file: code_repository_1-0-6.zip
File size: 638.23 KiB

Modification overview page: View

The phpBB Team is not responsible nor required to provide support for this modification. By installing this MOD, you acknowledge that the phpBB Support Team or phpBB Extensions Team may not be able to provide support.

-->Modification support<--

phpBB Code Repository

Posted: Fri Jul 03, 2009 5:36 am
by DavidIQ
Modification validated/released

Notes:

phpBB Code Repository

Posted: Fri Jul 03, 2009 5:36 am
by Desdenova
This post has been reserved for the MOD author.

Re: phpBB Code Repository

Posted: Fri Jul 03, 2009 11:13 pm
by 3Di
Oky, what about a deepen description of what this MOD is about to do? :geek:

Many Thanks. :)

Re: phpBB Code Repository

Posted: Sat Jul 04, 2009 3:42 pm
by Desdenova
The phpBB Code Repository is a on-server system for viewing and managing access to source files and/or pictures on the server, within a subdirectory of the phpBB installation.
You can manage access to the Code Repository, viewing files within it, viewing images within it, downloading the files, and allowing syntax highlighting of source files through a set of permissions that the MOD creates on installation.

Oh, did I forget to mention syntax highlighting? You can do that through this MOD, as it uses GeSHi to highlight source file code according to the file's mimetype (which, if unavailable, the MOD falls back to file extension to determine the language to highlight with).

Also included is caching integration for the crawldir engine, so that crawldir() is not repeatedly run on the server, preventing high server load.
Crawldir's construction is also non-recursive to allow a full scan of a directory's contents, along with any subdirectory's contents, along with any sub-subdirectory's contents..you get the picture. Using a recursive function instead of a loop to do something repeatedly would eventually result in a segmentation fault, as iWisdom found out with his IRC bot iWeather. :lol:

Since it's all managed within phpBB, also, you can control who can access it. If you want to release some source files to supporters, just set the supporters group to have permission to do so.

Re: phpBB Code Repository

Posted: Sat Jul 04, 2009 6:05 pm
by 3Di
Interesting. Thanks for all of your work on this.

Regards. :)

Re: phpBB Code Repository

Posted: Sat Jul 04, 2009 10:51 pm
by UseLess
Greetings,

A note should be added that this mod requires php 5.

Try this:

Code: Select all

//		$i = 0;  //If anyone knows a way around having to use an incrementer in this, and it's just as effective, LET ME KNOW.
//		while(@sizeof($subdirs) > 0)
		foreach($subdirs as $i => $value)
		{
			$scan = scandir($subdirs[$i]);
			foreach($scan as $key => $item)
			{
				$filepath = $subdirs[$i] . '/' . $item;
				$relpath = substr($filepath, strlen($homepath));
				if($item == '.' || $item == '..' || $item == '.svn' || @is_link($filepath))
				{ 
					continue; 
				}
				if(is_dir($filepath))
				{
					if(in_array(($filepath), $ignore_dirs))
					{
						continue;
					}
					$subdirs[] = $filepath;
					$return['dirs'][] = $relpath;
					$return['subdirs'][$i + 1][] = $relpath;
				}
				else
				{
					if(in_array(($filepath), $ignore_files))
					{
						continue;
					}
					$return['files'][$i + 1][] = $relpath;
				}
			}
//			unset($subdirs[$i]);
//			$i++;
		}

Re: phpBB Code Repository

Posted: Sun Jul 05, 2009 2:03 am
by Desdenova
UseLess wrote:Greetings,

A note should be added that this mod requires php 5.

Try this:

Code: Select all

//		$i = 0;  //If anyone knows a way around having to use an incrementer in this, and it's just as effective, LET ME KNOW.
//		while(@sizeof($subdirs) > 0)
		foreach($subdirs as $i => $value)
		{
			$scan = scandir($subdirs[$i]);
			foreach($scan as $key => $item)
			{
				$filepath = $subdirs[$i] . '/' . $item;
				$relpath = substr($filepath, strlen($homepath));
				if($item == '.' || $item == '..' || $item == '.svn' || @is_link($filepath))
				{ 
					continue; 
				}
				if(is_dir($filepath))
				{
					if(in_array(($filepath), $ignore_dirs))
					{
						continue;
					}
					$subdirs[] = $filepath;
					$return['dirs'][] = $relpath;
					$return['subdirs'][$i + 1][] = $relpath;
				}
				else
				{
					if(in_array(($filepath), $ignore_files))
					{
						continue;
					}
					$return['files'][$i + 1][] = $relpath;
				}
			}
//			unset($subdirs[$i]);
//			$i++;
		}
I'm sorry, but this belief is incorrect. If you look at the file includes/crs/crs_misc_functions.php, you will see there is a PHP4 compatible scandir() alternative function defined for PHP4 usage.

Code: Select all

/**
* PHP4 Scandir alternative function, altered for phpBB MODDB specs
* Pulled from "Scandir for PHP4" blog post by Cory S.N. LaViska, at http://abeautifulsite.net/notebook/59 
* No context parameter, however.  Oh well...
*/
if(!function_exists('scandir')) 
{
    function scandir($directory, $sorting_order = 0)
    {
        $dh = opendir($directory);
        while(($filename = readdir($dh)) !== false)
        {
            $files[] = $filename;
        }
        if($sorting_order == 0)
        {
            sort($files);
        }
        else
        {
            rsort($files);
        }
        return($files);
    }
}
 
You probably didn't notice that compatibility function though, so no worries. ;)

As for the change in crawldir, I'll give that a look over and see if that would work within the function to produce the results needed. If so, you gets a cookie. :)

Re: phpBB Code Repository

Posted: Sat Aug 01, 2009 5:59 pm
by Mudjosh
I seem to be unable to click "Submit" in the ACP.. Or "Reset"

This poses a problem with the mod as I cannot activate it now.. I am 95% sure I installed it correctly.

Re: phpBB Code Repository

Posted: Sun Aug 02, 2009 12:43 am
by Desdenova
Mind posting the HTML source of the ACP module when you are viewing it, so I can track down the problem? :)

Re: phpBB Code Repository

Posted: Sun Aug 02, 2009 2:34 am
by Mudjosh
of course.. I could prolly figure it out myself.. But I didn't know if this was a known issue.

Here it is.. To me it looks normal.. :?

I haven't installed a mod in phpbb3 in around half a year.. I have refreshed the cache on all my styles (Both Themes and Templates) Anywho.. So here you go:

Code: Select all

<!-- INCLUDE overall_header.html -->
<!-- IF S_VERSION_KEYWORD -->
<!--
/**
*
*===================================================================
*
*  phpBB Code Repository -- ACP Module Template File
*-------------------------------------------------------------------
*	Script info:
* Version:		1.0.6 - "Juno"
* Copyright:	(c) 2008, 2009 | Obsidian -- Infinityhouse Creations
* License:		http://opensource.org/licenses/gpl-license.php  |  GNU Public License v2
* Package:		ACP
*
*===================================================================
*
*/
//-->
<!-- ENDIF -->

<a name="maincontent"></a>

<h1>{L_ACP_CRS_MAIN_SETTINGS}</h1>

<p>{L_ACP_CRS_MAIN_SETTINGS_EXPLAIN}</p>

<!-- IF S_ERROR -->
	<div class="errorbox">
		<h3>{L_WARNING}</h3>
		<p>{ERROR_MSG}</p>
	</div>
<!-- ENDIF -->

	<form id="acp_crs_main" method="post" action="{U_ACTION}">

		<!-- IF S_IN_VERSION_CHECK -->

			<!-- IF not UP_TO_DATE -->
				<div class="errorbox">
					<h3>{L_UPDATE_AVAILABLE}</h3>
					<p>{UPDATE_INSTRUCTIONS}</p>
				</div>
			<!-- ELSE -->
				<div class="successbox">
					<p>{L_CRS_IS_UP_TO_DATE}</p>
				</div>
			<!-- ENDIF -->

			<fieldset>
				<legend>{L_VERSION_CHECK}</legend>

				<dl>
					<dt><label>{L_CURRENT_CRS_VERSION}</label></dt>
					<dd><strong>{CURRENT_VERSION}</strong></dd>
				</dl>

				<dl>
					<dt><label>{L_REMOTE_CRS_VERSION}</label></dt>
					<dd><strong>{LATEST_VERSION}</strong></dd>
				</dl>

		<!-- ELSE -->
		
		<fieldset>
			<legend>{L_VERSION_CHECK}</legend>

			<dl>
				<dt><label>{L_CURRENT_CRS_VERSION}</label></dt>
				<dd><strong>{CRS_VERSION}</strong></dd>
			</dl>
		
		<!-- ENDIF -->

			<dl>
				<dt><label for="checkversion">{L_CHECK_FOR_UPDATES}</label></dt>
				<dd><input class="button2" type="submit" id="checkversion" name="checkversion" value="{L_RUN}" /></dd>
			</dl>
		</fieldset>
	

	<!-- IF S_FOUNDER -->
	<fieldset>
		<legend>{L_CRS_RECACHE}</legend>
		<form id="action_purge_crs_cache_form" method="post" action="{U_ACTION}">
			<dl>
				<dt><label for="recache">{L_CRS_RECACHE_FILES}</label></dt>
				<dd><input class="button2" type="submit" id="recache" name="recache" value="{L_RUN}" /></dd>
			</dl>
		</form>
	</fieldset>
	<!-- ENDIF -->

		<fieldset>
			<legend>{L_GENERAL_OPTIONS}</legend>
			<dl>
				<dt><label for="crs_source_path">{L_CRS_SOURCE_PATH}:</label><br /><span>{L_CRS_SOURCE_PATH_EXPLAIN}</span></dt>
				<dd><input id="crs_source_path" name="crs_source_path" value="{CRS_SOURCE_PATH}" type="text" maxlength="255" /></dd>
			</dl>

			<dl>
				<dt><label for="crs_enabled">{L_CRS_ENABLED}:</label><br /><span>{L_CRS_ENABLED_EXPLAIN}</span></dt>
				<dd><label><input type="radio" class="radio" id="crs_enabled" name="crs_enabled" value="1"<!-- IF CRS_ENABLED--> checked="checked"<!-- ENDIF --> /> {L_ENABLED}</label>
					<label><input type="radio" class="radio" name="crs_enabled" value="0"<!-- IF not CRS_ENABLED --> checked="checked"<!-- ENDIF --> /> {L_DISABLED}</label></dd>
			</dl>

			<dl>
				<dt><label for="crs_dump_geshi_css">{L_CRS_DUMP_GESHI_CSS}:</label><br /><span>{L_CRS_DUMP_GESHI_CSS_EXPLAIN}</span></dt>
				<dd><label><input type="radio" class="radio" id="crs_dump_geshi_css" name="crs_dump_geshi_css" value="1"<!-- IF CRS_DUMP_GESHI_CSS --> checked="checked"<!-- ENDIF --> /> {L_ENABLED}</label>
					<label><input type="radio" class="radio" name="crs_dump_geshi_css" value="0"<!-- IF not CRS_DUMP_GESHI_CSS --> checked="checked"<!-- ENDIF --> /> {L_DISABLED}</label></dd>
			</dl>
		</fieldset>


		<fieldset class="submit-buttons">
			<legend>{L_SUBMIT}</legend>
			<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />&nbsp;
			<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
			{S_FORM_TOKEN}
		</fieldset>
	</form>

<!-- INCLUDE overall_footer.html -->

Re: phpBB Code Repository

Posted: Sun Aug 02, 2009 1:13 pm
by Mudjosh
Nevermind. In firefox it worked. In Safari and IE it didn't.. 8-)

Re: phpBB Code Repository

Posted: Mon Aug 03, 2009 2:52 am
by Desdenova
That's odd. :shock:

Also, for the HTML...I mean the output, when you're viewing the page. Not the template file. :lol:

Re: phpBB Code Repository

Posted: Mon Aug 03, 2009 3:00 am
by Mudjosh
oh oops..

It might have just been an issue of needing a ton of page refreshes.. I remember a mod needing a lot of page refreshes before it shown up in the acp.. Maybe it was something similar.. anywho, it works well of course. :P

I would like to make only one suggestion though..

Is there anyway at all that you could add in a way to search within the Code Repository too. I know that after a mod is validated mod authors do not like to add features.. but just in case.. :P

Re: phpBB Code Repository

Posted: Mon Aug 03, 2009 1:54 pm
by Desdenova
What kind of search would you be talking about?

If it is in-file search, that can't happen. It would be too strenuous on the server to do something like that...GeSHi for a large file is bad enough as it is, crawldir() on a very deep set of directories is even worse.


However, I was thinking of building a jumpbox of directories indexed as a possible feature...would that be something similar to what you are referring to?