1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need Your Help: Fnd some sites with GENERIC php, js, html scripts for website development

Discussion in 'Web Design' started by srb888, Apr 29, 2013.

  1. srb888

    srb888 Elite Member

    Joined:
    Jul 30, 2008
    Messages:
    3,260
    Likes Received:
    5,067
    Gender:
    Male
    Occupation:
    WebzSurfer
    Location:
    Sun, Mon, Tue, WTF, Sat!!! :)
    Hi friends,

    I need your help in finding some good generic scripts for website development. I wish to use a library of generic scripts / codes (php / js / html / others) which can obviously be reused in website development to make the development easier, faster, and more generic.

    Do you know of such sites where the scripts are easily and freely available, and accompany good documentation?

    Thanks all, in advance! God bless!

    :)
     
  2. nocare

    nocare Junior Member

    Joined:
    Apr 29, 2013
    Messages:
    164
    Likes Received:
    81
    Location:
    Deep Code
    Honestly your best bet for quality code is GitHub. You could toy around with some inurl searches and see if that get's you anywhere.
    Generic scripts is really quite a broad thing to be looking for though... ahaha.

    Your going to need to sit down and determine at least a couple of areas to look into.
    For example:
    Image manipulation. GD, ImageMagik, etc and other media types
    External url interaction. curl, wget, Elinks, etc
    Mysql and other database related should be easy to find.
    ---Hell I throw the same db_connection function into every php script myself.
    Class Objects for local file management could be useful to look for
    There are countless search results for custon jQuery plugins that
    do quite astonishing things.

    I've got a simple picket fence encryption program I wrote a while back i'll throw in here if I manage find it.

    Some types of things in other programming languages would be easily applicable to php. Really... there is a ton out there if you look.

    Documentation is subject to a lot of factors. Some programmers are lazy, others feel their code is obvious and comment lightly.
    Others comment nearly every freaking line.
    I fall into that category... part of my cleanup proccess is just commenting damn near everything. Think of the newbs. :D

    You may want to take a look at coding support forums. Occasionally you can come across someones non-working or nearly-working code bit thats interesting.

    Take a look at large script sites as well. You might potentially rip out the functionality of a wordpress/joomla plugin or use it in future site.

    I could go on, but the TLDL here: the internet is big, search for where programmers hang out and mingle ;]

    Code:
    <?php    function picketFenceString($string)
        {
            $isOdd = (strlen($string) % 2); //Determine if length is even or odd
            $oddFlag = false;
            
            if ($isOdd == 0) //String is Even
            {
                $intLen = strlen($string);
            }
            elseif($isOdd == 1) // String is odd
            {
                $intLen = (strlen($string) - 1);
                $oddFlag = true;
            }
            
            $charArray = str_split($string); //Break our string into an array of each character.
            
            $first=array();
            $last=array();
            $count=0;
            
            foreach ($charArray as $key=>$val)
            {
                if (($key) >= ($intLen/2)) //Halfway through origional string, so populate second array now
                {
                    $last[$count] = $val; //We don't want our second array to start at anything other than 0, so we don't recycle the index like we do witht he first array
                    $count++;
                }
                else
                {
                    $first[$key] = $val;
                }
            }
            
            // Now we have two two arrays, of a string cut in half.
            // Keep in mind there are many many ways to perform this encryption, simple as it may be
            // But let us move on to the actual "picketing".
            // My goal when writing this was to take these two arrays, and place the second array into every other slot of the first array, and expanding it.
            // So that coding becomes [c,o,d] [i,n,g]
            // then becomes [c,i,o,n,d,g]
            // If the string is odd in length, such as programming, then we'll throw that in the front of the string.
            // this will preserve the string pretty well, so keep in mind taht this alone is a weak encryption
            
            $finalArray = array();
            $flipBit = false; //Determines which array to pull from, toggles each loop execution. For readability, I seperate the toggle
            $firstEx = true; //Since we throw the last character into the front, we want a flag for the first loop execution
            $firstIndex = 0;
            $lastIndex = 0;
            
            for($i=0;$i<=$intLen;$i++)
            {
                if ($oddFlag && $firstEx){
                    $finalArray[$i] = $charArray[$intLen];
                    $firstEx=false;
                }
                else //Not an odd string (anymore), so continue
                {
                    if (!$flipBit)
                    {
                        $finalArray[$i] = $first[$firstIndex];
                        $firstIndex++;
                    }
                    else
                    {
                        $finalArray[$i] = $last[$lastIndex];
                        $lastIndex++;
                    }
                }
                
                if ($flipBit){$flipBit=false;} // toggle
                elseif (!$flipBit){$flipBit=true;}
            }
            
            
            
            return $finalArray;
        }
        
        function undoPicketFenceString($string)
        {
            $isOdd = (strlen($string) % 2); //Determine if length is even or odd
            $oddFlag = false;
            
            if ($isOdd == 0) //String is Even
            {
                $intLen = strlen($string);
            }
            elseif($isOdd == 1) // String is odd
            {
                $intLen = (strlen($string) - 1);
                $oddFlag = true;
            }
            
            $charArray = str_split($string); //Break our string into an array of each character.
            
            $first=array();
            $last=array();
            $count=0;
    
    
            
            $finalArray = array();
            $flipBit = false; //Determines which array to pull from, toggles each loop execution. For readability, I seperate the toggle
            $firstEx = true; //Since we throw the first character into the back, we want a flag for the first loop execution
            $firstIndex = 0;
            $lastIndex = 0;
            
            for($i=0;$i<=$intLen;$i++)
            {
                if ($oddFlag && $firstEx){
                    $last[$intLen+1] = $charArray[0];
                    $firstEx=false;
                }
                else //Not an odd string (anymore), so continue
                {
                    if (!$flipBit)
                    {
                        $last[$lastIndex] = $charArray[$i];
                        $lastIndex++;
                    }
                    else
                    {
                        $first[$firstIndex] = $charArray[$i];
                        $firstIndex++;
                    }
                }
                
                if ($flipBit){$flipBit=false;} // toggle
                elseif (!$flipBit){$flipBit=true;}
            }
            
            $finalFirst = implode("", $last); //now to combine the arrays, we need two strings
            $finalLast = implode("", $first);
            
            $finalString = $finalFirst.$finalLast; //at this point, our string is 99.999% origional, however its its odd the first char will be incorrect, so lets fix that.
            if ($oddFlag)
            {
                $firstChar = substr($finalString, 0,1);
                $finalString = substr($finalString, 1);
                $finalString = $finalString.$firstChar;
            }
            
            return $finalString;
        }
        
        $text = "Programming is so much fun! *cues cheering crowd*";
        $text2 = implode("", picketFenceString($text));
        print ("Origional: <strong>".$text."</strong>");
        print ("<br>After: <strong>".$text2."</strong>");
        //print ("<br>After: <strong>".implode("", undoPicketFenceString($text2))."</strong>");
        print ("<br>After: <strong>".undoPicketFenceString($text2)."</strong>");
    ?>
     
    • Thanks Thanks x 1
    Last edited: Apr 29, 2013