vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Community Lounge (https://vborg.vbsupport.ru/forumdisplay.php?f=13)
-   -   Count Code Lines (https://vborg.vbsupport.ru/showthread.php?t=106659)

joeboo 01-29-2006 08:48 PM

Count Code Lines
 
Do any of you guys know of a program that can count the number of lines (PHP lines) of files? Like, selecting a folder where PHP files are stored and having it count all the lines of every file.

BamaStangGuy 01-29-2006 08:55 PM

Filburt may know since he has a huge project he is working on

sabret00the 01-30-2006 09:41 AM

Quote:

Originally Posted by joeboo
Do any of you guys know of a program that can count the number of lines (PHP lines) of files? Like, selecting a folder where PHP files are stored and having it count all the lines of every file.

you could write a function to do it in php

Lea Verou 03-17-2006 10:52 PM

I also need this...

(and I'm too lazy to write it in php :p)

filburt1 03-18-2006 05:08 PM

Quote:

Originally Posted by BamaStangGuy
Filburt may know since he has a huge project he is working on

I just wrote my own script that recursively enters each chosen directory and counts each file's lines. Not very good but it works.

Lea Verou 03-18-2006 05:35 PM

will you share? :)

filburt1 03-18-2006 09:41 PM

PHP Code:

<?php
$count 
0;

$delim strstr(PHP_OS"WIN") ? "\\" "/";

ob_implicit_flush();

$filenames = array();

function 
count_lines($path)
{
    global 
$delim$count$filenames;

    if (
$dir = @opendir($path))
    {
        while ((
$element readdir($dir))!== false)
        {
            if (
is_dir($path $delim $element) && $element != "." && $element != "..")
            {
                
count_lines($path $delim $element);
            }
            else if (
$element != "." && $element != ".." and
                    
strpos($element"vbms") !== false
                    
and !in_array($element$filenames))
            {
                
$filenames[] = $element;
                
$linecount sizeof(file($path $delim $element));
                echo 
$element " (<em>$linecount lines</em>)<br />";
                
$count += $linecount;
            }
        }
        
closedir($dir);
    }
}

$path "some directory";
count_lines($path);
$path "some other directory";
count_lines($path);

echo 
"<strong>$count</strong> total lines";
?>

Will need significant changes to work for your setup.

Lea Verou 03-18-2006 09:43 PM

Thanks!


All times are GMT. The time now is 09:49 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01027 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete