Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

I have counted the line Of Osc


Gyakutsuki

Recommended Posts

Do you know exactly the number of line, directory .. has Osc.

 

There an answer :

 

Take in consideration only the .php and .css

  • Folders: 184
  • Files: 192 (1102 excluded)
  • Lines: 12257; Empty: 1455; Comment: 1277; Total: 14989
  • Tot. Size: 1.1889686584473 MB

Ok, What we do with that ? Heu :)


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

For a fresh copy of osC 2.3.4BS, I count

  • 159 folders
  • 1214 files
    • 766 PHP files
    • 448 non-PHP files
  • 8.25MB total file sizes
    • 3.9MB PHP files

I didn't bother breaking down PHP files by blank and comment lines. It looks like either your installation is severely corrupted, or your counting methods leave something to be desired.

Link to comment
Share on other sites

I jus use this, you can try and select some options

<?php
//////////////////////////////////////////////////////////////////////
// stats.php
//--------------------------------------------------------------------
//
// Statistics for your webserver
//
//--------------------------------------------------------------------

######################################################################
### MODIFY
######################################################################

  $directory_start = $_SERVER['DOCUMENT_ROOT'] . '/test/ms234/';

######################################################################
### STOP MODIFY
######################################################################
/////////////////////////////////////////////////////////////////
// Variable Declaration
/////////////////////////////////////////////////////////////////
$all_extensions = array();
$unite_spec = array("bytes","KB","MB","GB","TB");
$count_val = array(
	0,		// Comment
	0,		// Line
	0,		// White Line
	0,		// Count Dir
	0,		// Excluded Files
	0,		// Included Files
	0		// Size
);
$start_comment=false;

/////////////////////////////////////////////////////////////////
// Function Declaration
/////////////////////////////////////////////////////////////////
/**
 * Lit toutes les extensions pr�sentes dans $directory et les
 * enregistre dans $all_extensions (anti-doublon)
 *
 * @[member='param'] string $directory
 * @[member='param'] string[] $all_extensions
 */
function checkextension($directory, &$all_extensions){
	if (($handle = @opendir($directory))!==false) {
		while (($file = readdir($handle))!==false) {
			if((is_dir($directory.'/'.$file))&&($file != '.' && $file != '..')){
				checkextension($directory.'/'.$file, $all_extensions);
			}
			elseif($file != '.' && $file != '..'){
				$extension=explode('.',$file);
				// Si le fichier n'a pas de point, on ne le met pas !
				$check = ((strpos($file,'.')===false)?'':'.').$extension[count($extension)-1];
				if(!in_array($check,$all_extensions))
					$all_extensions[] = $check;
			}
		}
		closedir($handle);
	}
}

/**
 * Permet d'afficher dans la bonne unit�e les octets pass�
 * en param�tre.
 *
 * @[member='param'] int $octet
 * @[member='Return'] string
 */
function unite($octet){
	global $unite_spec;

	$count=0;
	while($octet>=1024){
		$count++;
		$octet/=1024;
	}
	return($octet.' '.$unite_spec[$count]);
}

/**
 * V�rifie ce que contient $ligne
 * Permet de v�rifier si le commentaire est d�j� commenc� avec /* ($start_comment)
 * Retourne
 *  - 0 : Commentaire
 *  - 1 : Ligne
 *  - 2 : Ligne Vide
 *
 * @[member='param'] string $ligne
 * @[member='Return'] int
 */
function checkline($ligne){
	global $start_comment;

	$ligne = trim($ligne);
	if((substr($ligne,0,2)=='/*')&&(substr($ligne,strlen($ligne)-2)=='*/'))return 0;
	elseif((substr($ligne,0,2)=='/*')&&($start_comment==false)){$start_comment=true;return 0;}
	elseif((substr($ligne,0,2)=='*/')&&($start_comment==true)){$start_comment=false;return 0;}
	elseif((substr($ligne,strlen($ligne)-2,2)=='*/')&&($start_comment==true)){$start_comment=false;return 0;}
	elseif(substr($ligne,0,2)=='//')return 0;
	elseif(substr($ligne,0,1)=='#')return 0;
	elseif($start_comment==true)return 0;
	elseif($ligne=='')return 2;
	else return 1;
}

/**
 * Scan le $directory et enregistre les statistiques
 *
 * @[member='param'] string $directory
 */
function readdirectory($directory){
	global $only_exclude,$extension_to_exclude,$extension_to_include,$count_val,$start_comment;

	if (($handle = opendir($directory))!==false) {
		while (($file = readdir($handle))!==false) {
			if((is_dir($directory.'/'.$file))&&($file != '.' && $file != '..')){
				$count_val[3]++;		// Dir ++
				readdirectory($directory.'/'.$file);
			}
			elseif($file != '.' && $file != '..'){
				$extension=explode('.',$file);
				$check = ((strpos($file,'.')===false)?'':'.').$extension[count($extension)-1];
				if($only_exclude==true && in_array($check,$extension_to_exclude)){
					$count_val[4]++;	// Excluded File ++
				}
				else{
					if($only_exclude==false && !in_array($check,$extension_to_include))
						$count_val[4]++;	// Excluded File ++
					else{	// We don't count THIS file !
						if(($directory.'/'.$file)!=($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'])){
							$count_val[5]++;	// Included File ++
							$count_val[6]+=filesize($directory.'/'.$file);		// Size
							$fp = fopen($directory.'/'.$file,'r');
							while(!feof($fp)){
								$buffer = fgets($fp,255);
								$count_val[checkline($buffer)]++;
							}
							// Lorsqu'un fichier est termin�, on remet le $start_comment � false
							$start_comment=false;
						}
					}
				}
			}
		}
		closedir($handle);
	}
}

/////////////////////////////////////////////////////////////////
// Program Starts
/////////////////////////////////////////////////////////////////
checkextension($directory_start, $all_extensions);

$choice = (isset($_POST['choice']))?$_POST['choice']:1;

echo '<html>
<head><title>Stats File</title></head>
<body bgcolor="#ffffff">';

echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<table width="550" border="1" align="center">
<tr><th colspan="2">Browsing Files</th></tr>
<tr><td>Search</td><td>
<input type="radio" name="choice" value="1" id="radio1"';if($choice==1)echo' checked="checked"';echo' /> <label for="radio1">Include</label><br />
<input type="radio" name="choice" value="2" id="radio2"';if($choice==2)echo' checked="checked"';echo' /> <label for="radio2">Exclude</label>
</td></tr>
<tr><td>Extension</td><td>';
for($i=0;$i<count($all_extensions);$i++){
	echo '<input type="checkbox" name="extension['.$i.']" value="1" id="choice'.$i.'"';
	if(isset($_POST['extension'][$i]) && $_POST['extension'][$i]==true)
		echo ' checked="checked"';
	echo' /> <label for="choice'.$i.'">'.$all_extensions[$i].'</label><br />';
}
echo '</td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Search" /></td></tr>

</table>
</form>';

$extension_to_exclude = array();
$extension_to_include = array();
if($choice==2){
	$only_exclude = true;
	$compteur=0;
	for($i=0;$i<count($all_extensions);$i++)
		if(isset($_POST['extension'][$i]) && $_POST['extension'][$i]==true)
			$extension_to_exclude[$compteur++] = $all_extensions[$i];
}
else{
	$only_exclude = false;
	$compteur=0;
	for($i=0;$i<count($all_extensions);$i++)
		if(isset($_POST['extension'][$i]) && $_POST['extension'][$i]==true)
			$extension_to_include[$compteur++] = $all_extensions[$i];
}

readdirectory($directory_start);
$count_total = $count_val[0]+$count_val[1]+$count_val[2];
echo '<table width="550" border="1" align="center"><tr><td>
<ul>Details <b>'.$directory_start.'</b><br />';
if($only_exclude==true){
	echo '<i>(The files with extension';
	for($i=0;$i<count($extension_to_exclude);$i++)
		echo ' '.$extension_to_exclude[$i].',';
	if(count($extension_to_exclude)==0)
		echo ' <u>NONE</u>';
	echo ' has not been counted.)</i>';
}
else{
	echo '<i>(ONLY The files with extension';
	for($i=0;$i<count($extension_to_include);$i++)
		echo ' '.$extension_to_include[$i].',';
	if(count($extension_to_include)==0)
		echo ' <u>NONE</u>';
	echo ' has been counted.)</i>';
}
echo '<li> Folders: <b>'.$count_val[3].'</b></li>
<li>Files: <b>'.$count_val[5].'</b> <i>('.$count_val[4].' excluded)</i></li>
<li>Lines: <b>'.$count_val[1].'</b>; Empty: <b>'.$count_val[2].'</b>; Comment: <b>'.$count_val[0].'</b>; Total: <b>'.$count_total.'</b></li>
<li>Tot. Size: <b>';
echo unite($count_val[6]);
echo '</b></li>
</ul>
</td></tr></table>';


echo '</body>
</html>';
clearstatcache();
?>


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

I used a "bash" window to count files and directories, and a Windows command line to do a dir /s and get the sizes. That's how I came up with my numbers. I haven't examined your script in detail, but it sounds like it's missing a lot of the installation! By the way, mine was a fresh unpack of the zip file, not a running post-installation site. osC 2.3.4 "Gold" is a bit different, but should be in the same ballpark.

Link to comment
Share on other sites

i think it would be interesting to see how this has changed since 2.2, and might be reduced further if language files are dropped as well as support for ancient php versions ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

@@MrPhil, the analyse is not on osC 2.3.4BS but the official version (with just php and css files).

@14steve14 nothing to do, it's just an information but It's possible to compare the old version with new version

 

If you want to evaluate the cost of development, you can read this document and try to calcul :

https://ifs.host.cs.st-andrews.ac.uk/Books/SE7/SampleChapters/ch26.pdf


Regards
-----------------------------------------
Loïc

Contact me by skype for business
Contact me @gyakutsuki for an answer on the forum

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...