by emran

JCow’s Events Join Modification

4:32 pm in Elgg, JCow by emran

I love jcow script.it is very nice and faster. It is very simple to implement in production website though some modification is required.

I found that in the Event module,  “i want to join” button always keep front even user already clicked the join button.it should not show if user already join on the event.

It can be changed easily.Please follow the steps to modify:

1. Go to modues/events/events.php

2. go to line no 70. where u will find hook_viewstory() function.

then you place code as following.

Events join modification

Events join modification

3. Now refresh the events page and check that it will not show if you already join the event.

That’s all

by emran

Shoutbox Module for JCow

9:45 am in JCow by emran

I have written another module for JCow.It is shoutbox.

The Shoutbox module provides a block where visitors can quickly post short messages.

  • Post messages instantly via AJAX
  • Optionally have messages auto-refresh via AJAX
  • A cron option allows the administrator to have old shouts deleted.[not implemented yet]

Let me know if you have any issues.

JCow Shoutbox

JCow Shoutbox

How to setup:

1. Download the Modules shoutbox.

2.  Copy and paste the modules to the directory modules/shoutbox

3. Go to Admin CP and Install shoubox module

4. Then edit dashboard script from modules/dashboard.php and put the following code in the index() function

//after this code
block(
friends_birthday()
);

//Add this Code

include_once ‘modules/shoutbox/shoutbox.php’;

$sb=new shoutbox();
block(
$sb->shout_box()
);

by admin

SEO friendly URL in PHP

2:29 pm in CMS, Elgg, PHP by admin

You can make SEO Friendly url easily in php.

function friendlyURL($string){
	$string = preg_replace("`\[.*\]`U","",$string);
	$string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string);
	$string = htmlentities($string, ENT_COMPAT, 'utf-8');
	$string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string );
	$string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string);
	return strtolower(trim($string, '-'));
}

usage:

$myFriendlyURL = friendlyURL("Barca rejects FIFA statement on Olympics row");
echo $myFriendlyURL; // will echo barca-rejects-fifa-statement-on-olympics-row

by emran

Jcow Social Script Admin Add User

3:48 pm in Elgg, JCow by emran

I saw some request in JCow forum about user add from admin panel.
So i gave sometimes and it works.

Here is the code:

1. First you have to edit modules/admin/admin.php

and put these two function.

function useradd(){
nav(t(‘Users/Add User’));
section_content(‘
<fieldset>
<form action=”‘.url(‘admin/useraddpost’).’” method=”post”>
‘);

section_content(‘
<p>
‘.label(‘Full Name’).’
<input type=”text” name=”fullname” size=30 />
</p>

<p>
‘.label(‘Username’).’
<input type=”text” name=”username” size=30 />
</p>
<p>
‘.label(‘Password’).’
<input type=”text” name=”password” size=30 />
</p>
<p>
‘.label(‘E-mail’).’
<input type=”text” name=”email” size=30 />
</p>
<p>
‘.label(t(‘Gender’)).’
<input type=”radio” name=”gender” value=1 checked/> Male
<input type=”radio” name=”gender” value=0 /> Female
<input type=”radio” name=”gender” value=2 /> Hide<br />
</p>

<p>
‘.label(t(‘Status’)).’
<input type=”radio” name=”disabled” value=0 checked/> Active
<input type=”radio” name=”disabled” value=1 /> Pending
<input type=”radio” name=”disabled” value=2 /> Suspended<br />
</p>

<p>
<input type=”submit” value=”‘.t(‘Add User’).’” />
</p>
</form>
</fieldset>’);
}

the above function will show form to add user.

function useraddpost(){

$_POST['username'] = strtolower($_POST['username']);

if (strlen($_POST['username']) < 4 || strlen($_POST['username']) > 18 || !ereg(“^[0-9a-z]+$”,$_POST['username'])) {
$errors[] = t(‘Username’).’: ‘.t(‘from 4 to 18 characters, only 0-9,a-z’);
}

if (!$_POST['email'] || !$_POST['fullname'] || !$_POST['username'] || !$_POST['password']) {
$errors[] = t(‘Please fill in all the required blanks’);
}

if(!eregi(“^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$”, $_POST['email'])) {
$errors[] = t(‘Unavailable email address’);
}

$password = md5($_POST['password'].’jcow’);
$timeline = time();
$res = sql_query(“select * from `”.tb().”accounts` where email=’{$_POST['email']}’”);
if (sql_counts($res)) {
$errors[] = t(‘You have registered with this email address before.’);
}
$res = sql_query(“select * from `”.tb().”accounts` where username=’{$_POST['username']}’”);
if (sql_counts($res)) {
$errors[] = t(‘The Username has already been used’);
}

if(!is_array($errors)){

sql_query(“insert into `”.tb().”accounts` (hide_age,gender,disabled,password,email,username,fullname,created) values
(’1′,”.$_POST['gender'].”,”.$_POST['disabled'].”,’$password’,'”.$_POST['email'].”‘,’”.$_POST['username'].”‘,’”.$_POST['fullname'].”‘,’”.$timeline.”‘)”);
$uid = insert_id();
sql_query(“insert into `”.tb().”profiles` (id,style_ids) values($uid,’3|3|3′)”);
stream_publish(t(‘Signed Up’),”,”,$uid);
t(‘Congratulations! You have successfully created user.’);
redirect(“admin/users”);
}else {
foreach ($errors as $error) {
$error_msg .= ‘<li>’.$error.’</li>’;
}
sys_notice(t(‘Errors’).’:<ul>’.$error_msg.’</ul>’);
}

}

The above function will add user after submitting.

2. Now add this line to users() function of admin.php files.

c(“<p><a href=”.url(“admin/useradd”).”>Add User</a></p>”);

Jcow Admin Add user

Jcow Admin Add user Link

3. That’s all. Go to admin panel->members->add user. i hope rest of work you can do:P..

Download the source code.

Jcow Admin Add user Source

by admin

Hide Admin user from recent login in JCow Social script

2:50 pm in Elgg, JCow by admin

you can apply a tricks not to show admin on the recent logins or recent members like this.

Open theme’s page.tpl.php and go to line no 170.

Change with following query.it will not show admin.

$res = sql_query(“SELECT * from `”.tb().”accounts` where roles!=3 order by lastlogin desc limit 20″);

by emran

SMTP Module at JCow Social Script

1:28 pm in Elgg, JCow by emran

This is my first module for JCow Social script. Sometimes we need remote SMTP server to send out email.This script will help you to send out email from remote SMTP server even gmail or yahoo.It supports SSL connection too.

First, You need to download class.smtp.php and class.phpgmailer.php scripts and place into  includes/libs/ folder under JCow directory.

Now add these files to boot.inc.php from includes/ folder.

//loading SMTP Library
require_once ‘./includes/libs/class.phpgmailer.php’;
require_once ‘./includes/libs/class.smtp.php’;

Now edit my/config.php files and put smtp parameters as like follows:

$config['smtp_host']=’127.0.0.1′;
$config['smtp_port']=25;
$config['smtp_auth']=true;
$config['smtp_user']=’YOUR USERNAME’;
$config['smtp_pass']=’YOUR PASSWORD’;
$config['smtp_html']=true;
$config['smtp_from']=’noreply@YOURDOMAIN’;

Now the final step. Edit includes/libs/common.inc.php and write mailer function :

function jcow_user_mail($to,$subject,$message,$reply=”){
global $config;
$mail = new PHPGMailer();
$mail->Username = $config['smtp_user'];
$mail->Password = $config['smtp_pass'];
$mail->From = $config['smtp_from'];
$mail->FromName = get_gvar(‘site_name’);
$mail->Host=$config['smtp_host'];
$mail->Port=$config['smtp_port'];
$mail->Subject = $subject;
$mail->AddAddress($to);
$mail->Body = $message;
$mail->IsHTML=$config['smtp_html'];;

return $mail->Send();

}

Now all email will send out via SMTP server.This is tested script.

Download SMTP Module for JCow

by admin

JCow as Opensource Social Networking script

1:10 pm in Elgg, JCow by admin

Few days back, I was asking to make a website for a alumni association.They need a function as like facebook.After that I had started searching on google.I found have few scripts.Out of them, I liked three scripts i.e. Elgg,  Dolphin and JCow.

I discover that JCow is nicely developed.Although, i was strange to see the name “JCow” as social networking script.It is very easier to extend.It is very lightweight and faster than others. So i decided to work on JCow.JCow has some lack of features but it can be extended easily.I have written some scripts for my website.I will share it soon.

Happy JCowing……!

by emran

Use wget with Squid Proxy Server

1:01 pm in Linux by emran

you can pass the proxy username and password as follows:
wget –proxy-user=YOUR-USERNAME-HERE –proxy-password=YOUR-PASSWORD-HERE http://nixcraft.com/file.tar.gz

by admin

IVR Application in Lua for Freeswitch

5:57 pm in FreeSWITCH, Lua by admin

1. Create a New file name 01_Custom.xml and add the following new extension:

<extension name=”Read Back Entered Digits”>
<condition field=”destination_number” expression=”^(9910)$”>
<action application=”lua” data=”test1.lua”/>
</condition>
</extension>

2. Save the file. Launch fs_cli and issue reload_xml, or press F6.

Our Dialplan is now ready to call the Lua script named test1.lua. Create this new script as follows:

1. Using your text editor, create test1.lua in the freeswitch/scripts/ directory and add the following lines:

– test1.lua
– Answer call, play a prompt, hangup

– Set the path separator
pathsep = ‘/’ — Windows users do this instead:
– pathsep = ‘\’

–Answer the call
session:answer()

–Create a string with path and filename of a sound file
prompt = “ivr” .. pathsep .. “ivr-welcome_to_freeswitch.wav”

– Print a log message
freeswitch.consoleLog(“INFO”,”Prompt file is ‘” .. prompt .. “‘\
n”)

–Play the prompt
session:streamFile(prompt)

– Hangup
session:hangup()

2. Save the file.

Now dialer 9910 and you will get IVR.

by admin

Lua Tutorial for Freeswitch

5:52 pm in FreeSWITCH, Lua by admin

Lua is very lightweight programing language.Lua has a simple syntax that is easy both to learn and to read. Following is a
simple script:

— This is a sample Lua script
— Single line comments begin with two dashes

–[[
This is a multi-line comment.
Everything between the double square brackets
is part of the comment block.
]]

— Lua is loosely typed
var = 1 — This is a comment
var = �alpha� — Another comment
var = �A1� — You get the idea…

–[[
When the Lua script is called from the dialplan
you have a few magic objects. A handy one is
the 'freeswitch' object which lets you do things
like this:
freeswitch.consoleLog(�INFO�,�This is a log line\n�)

Another important one is the 'session' object which
Lets you manipulate the call:
session:answer()
session:hangup()
]]

— Lua makes extensive use of tables
— Tables are a hybrid of arrays and associative arrays
my_table = {
key1 = val1,
key2 = val2,
�index 1�,
�index 2�
}
freeswitch.consoleLog(�my_table key1 is ‘� .. my_table[key1] .. �’\n�)
freeswitch.consoleLog(�my_table index 1 is ‘� .. my_table[1] .. �’\n�)

— Access arguments passed in
arg1 = argv[1] — First argument
arg2 = argv[2] — Second argument

— Simple if/then
if ( var == �A1� ) then
freeswitch.consoleLog(�INFO�,�var is ‘A1′\n�)
end

— Simple if/then/else
if ( var == �A1� ) then
freeswitch.consoleLog(�INFO�,�var is ‘A1′\n�)
else
freeswitch.consoleLog(�INFO�,�var is not ‘A1′!\n�)
end

— String concatenation uses ..
var = �This � .. � and � .. �that�
freeswitch.consoleLog(�INFO�,�var contains ‘� .. var .. �’\n�)

— The end

Every Lua script that is executed from the Dialplan receives the session object,
which represents the call leg that is being processed. The session object is the
primary means of manipulating the call, and is used extensively in Lua scripting.