PHP script execution time and Bulk Mail sending in Moodle

In Moodle there is an option to send mails to bulk users. By default it will send maximum 30 to 50 mails only, because the script execution time is 30 sec by default. So you need to change the script execution time not in php.ini. When you change the execution time limit in php.ini it will effect on all scripts in your application. You need to need to say the execution time  for the particular script, by add the line in beginning of the php script(ie., next to <?php) as “set_time_limit(0);” 0 means unlimited.

File size validation on client side with Jquery

<head>

<script language=”JavaScript” src=”jquery.js”>

</script>

<script language=”Javascript”>

$(‘document’).ready(function() { $(‘#loadfile’).change(function() { var fileInput = $(this)[0]; var fsize = fileInput.files[0].fileSize; if(fsize >10485760) { alert(“please upload file less than 10 MB”); $(this).val(”); } }); });

</script>

</head><input type=”file” id=”loadfile” /><input type=”button” value=”find size” id=”load” />

Moodle

I got a chance to know about Moodle. I my words we can build a LMS through CMS called Moodle. Moodle is coded by php , so its easy to play with php code. We can create our own models also in it.

It’s easy to install , just need to download base on Linux, Mac & Windows. For Linux and Mac extract the pack and put it in XAMPP. For windows moodle.exe or another way WAMPP.

We can install different language packages and themes , also we can build own themes.

CPAN Packages Installation script

This is the script which is useful to install the minimum require CPAN packages. Just runt the script, it will install the package one by one. And no need to say yes while install each package.

package.txt

DBI
Archive::Extract
Array::Diff
Array::Unique
Benchmark::Stopwatch
Catalyst::Request::Upload
Catalyst::Model::DBIC::Schema
Catalyst::Controller
Catalyst::Controller::FormBuilder Catalyst::Controller
Catalyst::Controller
Catalyst::Plugin::ConfigLoader
Catalyst::Plugin::Session::State::Cookie
Catalyst::Plugin::Static::Simple
Catalyst::Request::Upload
Data::Compare
Data::Dumper
Data::Page
Date::Calc
Date::Parse
DateTime::Duration
DateTime::Format::Strptime
DBIx::Class
DBIx::Class::Core
DBIx::Class::ResultSet
DBIx::Class::Schema
DBIx::Class::Schema
DBICx::TestDatabase
Digest::MD5
Encode
Exporter
FCGI
FFmpeg::Command
File::Basename
File::Copy
File::Path
File::Type
For::Else
Hash::Search
HTTP::Cookies
HTTP::Headers
HTTP::Request
HTTP::Request::Common
HTTP::Response
JSON
List::Util
Moose
namespace::autoclean
POSIX
Quantum::Superpositions
Storable
String::Random
Switch
Test::Deep
Test::More
Text::CSV::Slurp
WWW::Curl::Easy
XML::Simple
YAML
Sub::Identify
Variable::Magic
Catalyst
Catalyst::Devel
Catalyst::Engine::HTTP
Catalyst::Plugin::Session::Store::FastMmap
Catalyst::Plugin::Authentication::Credential::Password
Catalyst::Plugin::Authorization::Roles
Catalyst::Plugin::Authorization::ACL
Catalyst::Plugin::Cache::FastMmap
Catalyst::Engine::HTTP::Prefork
Catalyst::Authentication::Store::DBIx::Class
Catalyst::Plugin::Authentication::Store::LDAP
Catalyst::View::TT
Catalyst::View::Email::Template
Catalyst::View::Jemplate
Catalyst::View::JSON
FCGI
Catalyst::Engine::FastCGI
DateTime
String::Strip
HTML::Strip
DBIx::Class::TimeStamp
Clone
WWW::Curl::Easy
DateTime::Format::Atom
Data::ShowTable
Data::SearchEngine::Solr
Solr
MooseX::NonMoose

install_script.pl

#!/usr/local/bin/perl
use File::Compare;
#AUTHOR MANIKANADN . R

@ln=`cat package.txt`;

foreach $lin (@ln)
{

system(“PERL_MM_USE_DEFAULT=1 cpan -f $lin”); # “perl_mm_use_default” this is to say yes whenever the shell ask yes or no for install a package.(Niranjan– who is my clique )

}

No need to watch the installation process by sit near by machine, it will install automatically everything. I hope this will mostly use full while install Catalyst in Servers.

If you have copy of of working catalyst application which is working in another machine and you are going to install in new machin , then use the below script to find list of packages used in it.

fetch_package.pl

#!/usr/local/bin/perl
use File::Compare;
#AUTHOR MANIKANADN . R
#This script will grep the lines which exactly match “use” string form all the folders(and sub folders) of give destination folder.
if ($#ARGV<0 || $#ARGV>0)
{
print “pass only one  ARGUMENT ‘pathofsourcefolder’ \n”;
print “Eg: fetch_use_list.pl SRCPATH \n”;
exit;
}
$src= $ARGV[0];
`grep -w -h -ir use $src >test.txt`;
`sort test.txt > package.txt`;
`uniq package.txt > test.txt`;
`sed ‘s/use//g’ test.txt>package.txt`;
`sed /#/d package.txt >test.txt`;
`sed ‘s/base//g’ test.txt>package.txt`;
`rm test.txt`;

run this script with on arg(path of lib in catalyst application folder). Eg. /home/mani/proj/catapp/lib/

after this done it will get list all packages(99%) which is used in that application, then open the package.txt file and check for unwanted lines and char like  [ ‘  ,  ] in beginning of the CPAN package name. Then use the same script(install_script.pl) above to install packages.

Eg:

If the package looks like ‘Catalyst::Controller’ or require/use ‘Catalyst::Controller’  , just remove the quotes(‘) and words require/use.