Installation

In this article, we help you to start and configure ArrowChat by running the web installation. Make sure you've read the requirements before continuing.


Sections in this article

Quick Start Guide

If you're experienced in creating websites and installing scripts, we recommend you use the quick start guide to save some time. If you're new, no sweat, just start with our Installation Video or Uploading section.


  • Upload ArrowChat

    Unzip the ArrowChat zip file and extract the arrowchat folder. Upload the arrowchat folder to your server using your favorite FTP program.

  • Run the Web Installer

    Visit http://www.yoursite.com/arrowchat/install/ in your browser (replacing yoursite.com with your own domain). The web installer will guide you through all the steps required to install ArrowChat.

  • Custom Installations

    This step is only required if you are not using ArrowChat with one of our supported integrations. If you want to integrate ArrowChat with your site's login system, usernames, avatars, and more, you'll need to setup the includes/config.php and includes/integration.php files. Please see the Custom Installations section for more information.


Installation Video

If you prefer, you can watch a video below that explains the installation step-by-step. This video does not cover the extra steps required for custom installations but it is still useful for them.


Uploading

In this section, we'll take you through the process of unzipping and uploading ArrowChat to your server. If you already know how to do this, you can skip to the web installer section.

Step 1 - Unzip and Extract

The first step is to extract the ArrowChat .zip file. This will slightly vary depending on your operating system and the program you use. Generally, you will right click on the icon and choose Extract Here.

Unzip ArrowChat

After extraction, you should have an arrowchat folder and an INSTRUCTIONS.txt file.

Step 2 - Uploading to your Server

You will then need to upload the arrowchat folder to your web server. Typically, you will use an FTP program to do this but you can use your own method of choice for placing files on your server. We recommend the following programs:

You'll need to connect to your server using the details that your server provider gives you. Please contact your host if you are unsure.

Lastly, just drag and drop the arrowchat folder onto your server's root folder (public_html or www). If you are installing on a supported integration, place the arrowchat folder in the integration's folder. For example, /public_html/forum/arrowchat/ if you are installing on forum software where your forum has a separate folder apart from your main site called forum.

Upload ArrowChat

Web Installer

The next step is to visit http://www.yoursite.com/arrowchat/install/ in your browser (replacing yoursite.com with your own domain). The web installer will guide you through all the steps to install ArrowChat. Browse through each tab below if you need additional help.

The requirements section is simply checking to make sure your server is setup to install ArrowChat properly. If something isn't right, it will show up in red with information on what you need to do.

Web Installation Requirements
Fixing Files that are Not Writable

In order to fix files that are not writable, you will need to CHMOD them to 777 permissions. Typically, you can do this in your FTP program by right-clicking the file and selecting properties. You can then either enter 777 or select ALL of the R, W, and X checkboxes.

Fixing Missing Files

Simply re-download ArrowChat and upload the files again if you are missing files.

In the database section, you'll choose your installation type and enter your database details. It is important that you select the correct integration and version.

Web Installation Database
Filling out the Database Details

In the database details section, you'll want to enter the database details for the existing database for your site. This is important so that ArrowChat can read user information. You can either look in a configuration file on your site or contact your host for these details.

Database Host: This is the server address of your database. 99% of the time, this will be localhost. You can also enter a port number using the following format: 123.456.789:1234.
Database Name: The name of your database. Remember to use your exisint user database. Do not create a new database unless you do not already have one.
Username: The username of a user that has full permissions to your database.
Password: The password for the user on your database.
MSSQL: Check the MSSQL checkbox if you are using MSSQL Server instead of MySQL.

In the administration section, simply fill out a username, password, and email for ArrowChat. This user will have full control over changing settings within ArrowChat. The email will only be used for lost password recovery.

Web Installation Administration

The configuration section allows you to choose basic ArrowChat settings to help you setup ArrowChat the way you want it. Don't worry too much about this as the settings can be changed later.

Database Prefix

Most of the time, this setting is correct as ArrowChat automatically guesses the correct setting. What ArrowChat is looking for here is if you database has any characters before each table name. For example, if you have a phpfox_user table then phpfox_ is most likely your database prefix.

The easiest way to find this out is by visiting your phpMyAdmin site (via cPanel or Plesk) and checking all the names of the databases.

Web Installation Database Prefix

In the screenshot above, you'll see that phpfox_ is the database prefix because it appears before each table name.

Web Installation Database Prefix

In the screenshot above, you'll see that there are no words or characters that appear before each table name. In this case, you would leave the table prefix blank.

Database Details for Custom Integrations

Custom integrations will need to fill out additional database details unless guest chat only was selected. This information can be edited later in the includes/config.php file and can be left blank for now except the user table.

Web Installation User Table
User Table: This is the name of the user table without the prefix. Using the screenshot above, we would enter users here.
Username Field: This is the username field located within the user table. Using the screenshot above, we would enter name here.
User ID Field: This is the user ID field located within the user table. Using the screenshot above, we would enter id here.
User Avatar Field: This is the avatar field located within the user table. If you do not have one or your avatar field is located in another field, please enter the same value you put for the User ID field. Do not leave this blank. Using the screenshot above, we would enter avatar here.
Web Installation Friends Table
Friends Table: This is the name of the friend table without the prefix. Using the screenshot above, we would enter friends here.
Friends User ID Field: This is one of the user ID fields in the friends table. Using the screenshot above, we would enter user_id here.
Friends Friend ID Field: This is the other user ID field not entered above. Using the screenshot above, we would enter friend_id here.
Friends Check Field: This is a field that checks whether the friend relationship has been approved or accepted. Not all sites will have this and you can leave it blank if you don't. Using the screenshot above, we would enter approved here.

Congratulations, you're almost done. These last few steps are critical to ArrowChat appearing on your site, though.

CHMOD Files

In order to change files back to 644 or 755, you will need to change the file permissions (CHMOD). Typically, you can do this in your FTP program by right-clicking the file or folder and selecting properties. You can then either enter 644/755 or select the R, W, and X checkboxes.

Header/Footer Code

Please see our Header/Footer Code section for help with this step.

Your installation is complete after you finish the web installation if you are on a supported integration. Custom integrations, please continue reading below.


Custom Installations

This section will go into detail about setting up ArrowChat with a website that is not on our supported integrations list. During this setup, you will find it useful to visit our debug page at http://www.yoursite.com/arrowchat/debug/ (replacing yoursite.com with your own domain).

The /includes/integration.php file is the main file that makes ArrowChat integrate with your site's login system, usernames, avatar, and more. Go ahead and open that file up now and we'll walk you through setting it up for your own site.

Function: get_user_id()

This function will simply return the user's ID or NULL if no user is logged in. The two most common ways to setup this function are by cookie and session.

Example

Make sure you uncomment session_start(); at the top of the file if using sessions.

function get_user_id() 
{
	$userid = NULL;
	
	if (!empty($_SESSION['userid']))
	{
		$userid = $_SESSION['userid'];
	}

	return $userid;
}

Make sure you uncomment session_start(); at the top of the file if using sessions.

function get_user_id() 
{
	global $db;
	
	$userid = NULL;
	
	if (!empty($_COOKIE['hash'])) 
	{		
		$result = $db->execute("
			SELECT user_id
			FROM " . TABLE_PREFIX . "session
			WHERE hash = '" . $db->escape_string($_COOKIE['hash']) . "'
		");

		if ($row = $db->fetch_array($result))
		{
			$userid = $row['user_id'];
		}
	}

	return $userid;
}

Function: get_friend_list()

This function controls a user's online list if showing friends only was selected.

Parameters
$userid The user ID of the person requesting the list.
$time The time of the request.
Example

This example assumes the following database structure:

--------------------------------------------------------------------------------
 id    DB_USERTABLE_USERID    DB_FRIENDSTABLE_USERID    DB_FRIENDSTABLE_FRIENDS
--------------------------------------------------------------------------------
 13            1                      2                            1
 14            2                      1                            1
--------------------------------------------------------------------------------

You can see that both user IDs 1 and 2 have database entries instead of their being one entry for both of them.

	function get_friend_list($userid, $time)
	{
		global $db;
		global $online_timeout;
		
		$sql = ("
			SELECT DISTINCT " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " userid, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " username, arrowchat_status.session_time lastactivity, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_AVATAR . " avatar, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " link, arrowchat_status.is_admin, arrowchat_status.status 
			FROM " . TABLE_PREFIX . DB_FRIENDSTABLE . " 
			JOIN " . TABLE_PREFIX . DB_USERTABLE . " 
				ON  " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_FRIENDID . " = " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " 
			LEFT JOIN arrowchat_status 
				ON " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " = arrowchat_status.userid 
			WHERE " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_USERID . " = '" . $db->escape_string($userid) . "' 
				AND " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_FRIENDS . " = 1 
				AND arrowchat_status.session_time > (" . time() . " - " . $online_timeout . " - 60)
			ORDER BY " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " ASC
		");
		
		return $sql; 
	}

This example assumes the following database structure:

--------------------------------------------------------------------------------
 id    DB_USERTABLE_USERID    DB_FRIENDSTABLE_USERID    DB_FRIENDSTABLE_FRIENDS
--------------------------------------------------------------------------------
 13            1                      2                           YES
 14            2                      1                            NO
--------------------------------------------------------------------------------

You can see that the approval field is either a YES or NO instead of a number.

	function get_friend_list($userid, $time)
	{
		global $db;
		global $online_timeout;
		
		$sql = ("
			SELECT DISTINCT " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " userid, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " username, arrowchat_status.session_time lastactivity, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_AVATAR . " avatar, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " link, arrowchat_status.is_admin, arrowchat_status.status 
			FROM " . TABLE_PREFIX . DB_FRIENDSTABLE . " 
			JOIN " . TABLE_PREFIX . DB_USERTABLE . " 
				ON  " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_FRIENDID . " = " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " 
			LEFT JOIN arrowchat_status 
				ON " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " = arrowchat_status.userid 
			WHERE " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_USERID . " = '" . $db->escape_string($userid) . "' 
				AND " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_FRIENDS . " = "YES" 
				AND arrowchat_status.session_time > (" . time() . " - " . $online_timeout . " - 60)
			ORDER BY " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " ASC
		");
		
		return $sql; 
	}

This example assumes the following database structure:

-----------------------------------------------------
 id    DB_USERTABLE_USERID    DB_FRIENDSTABLE_USERID
-----------------------------------------------------
 13            1                      2     
 14            2                      1      
-----------------------------------------------------

You can see that there is no approval field. The users are friends if there is an entry.

	function get_friend_list($userid, $time)
	{
		global $db;
		global $online_timeout;
		
		$sql = ("
			SELECT DISTINCT " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " userid, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " username, arrowchat_status.session_time lastactivity, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_AVATAR . " avatar, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " link, arrowchat_status.is_admin, arrowchat_status.status 
			FROM " . TABLE_PREFIX . DB_FRIENDSTABLE . " 
			JOIN " . TABLE_PREFIX . DB_USERTABLE . " 
				ON  " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_FRIENDID . " = " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " 
			LEFT JOIN arrowchat_status 
				ON " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " = arrowchat_status.userid 
			WHERE " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_USERID . " = '" . $db->escape_string($userid) . "' 
				AND arrowchat_status.session_time > (" . time() . " - " . $online_timeout . " - 60)
			ORDER BY " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " ASC
		");
		
		return $sql; 
	}

This example assumes the following database structure:

--------------------------------------------------------------------------------
 id    DB_USERTABLE_USERID    DB_FRIENDSTABLE_USERID    DB_FRIENDSTABLE_FRIENDS
--------------------------------------------------------------------------------
 13            1                      2                            1
 14            3                      4                            1
 15            9                      2                            1
--------------------------------------------------------------------------------

In this example, there is only one entry when users are friends instead of two.

	function get_friend_list($userid, $time) 
	{
		global $db;
		global $online_timeout;
		
		$sql = ("
			SELECT DISTINCT " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " userid, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " username, arrowchat_status.session_time lastactivity, " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_AVATAR . " avatar, " . TABLE_PREFIX . DB_USERTABLE . ".user_nicename link, arrowchat_status.is_admin, arrowchat_status.status 
			FROM " . TABLE_PREFIX . DB_FRIENDSTABLE . " 
			JOIN " . TABLE_PREFIX . DB_USERTABLE . "  
				ON  " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_FRIENDID . " = " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " 
					OR  " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_USERID . " = " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " 
			LEFT JOIN arrowchat_status 
				ON " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_USERID . " = arrowchat_status.userid 
			WHERE ((" . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_USERID . " = '" . $db->escape_string($userid) . "')
					OR (" . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_FRIENDID . " = '" . $db->escape_string($userid) . "'))
				AND " . TABLE_PREFIX . DB_FRIENDSTABLE . "." . DB_FRIENDSTABLE_FRIENDS . " = 1 
				AND arrowchat_status.session_time > (" . time() . " - " . $online_timeout . " - 60)
			ORDER BY " . TABLE_PREFIX . DB_USERTABLE . "." . DB_USERTABLE_NAME . " ASC
		");
		
		return $sql; 
	}

Function: get_online_list()

This function controls a user's online list if showing all online users was selected.

Parameters
$userid The user ID of the person requesting the list.
$time The time of the request.

It is extremely rare that you need to change this function assuming your /includes/config.php file is setup correctly. Sometimes, you might need to alter the select statement if your avatar is not located in the user's table.

Function: get_user_details()

This function retrieves a user's ID, username, last activity time, profile link, avatar, and status.

Parameters
$userid The user ID of the person you are getting details on.

It is extremely rare that you need to change this function assuming your /includes/config.php file is setup correctly. Sometimes, you might need to alter the select statement if your avatar is not located in the user's table.

This function returns a user's profile link.

Parameters
$link This is the link variable in the SQL statements.
$userid The user ID of the person you are getting details on.
Example
	function get_link($link, $user_id) 
	{
		global $base_url;
		
		return $base_url . "../profile/" . $link;
	}
	function get_link($link, $user_id) 
	{
		global $base_url;
		
		return $base_url . "../member/" . $user_id;
	}

Function: get_avatar()

This function returns a URL for the user's avatar. If you site does not have avatars, you can return a # character.

Parameters
$image This is the avatar variable in the SQL statements.
$userid The user ID of the person you are getting the avatar for.
Example
	function get_avatar($image, $user_id) 
	{
		global $base_url;
		
		if (is_file(dirname(dirname(dirname(__FILE__))) . '/images/' . $image . '.gif')) 
		{
			return $base_url . '../images/' . $image . '.gif';
		} 
		else 
		{
			return $base_url . AC_FOLDER_ADMIN . "/images/img-no-avatar.png";
		}
	}
	function get_avatar($image, $user_id) 
	{
		return "https://www.gravatar.com/avatar/" . md5($image) . "?d=identicon";
	}

Function: get_group_id()

This is an optional function. You can customize it if you have groups to enable group permissions such as premium members having access to different features. It returns an array of all the groups that a user is a part of.

Parameters
$userid The user ID of the person you are getting the groups for.
Return Example
	 Array
	 (
	 	[0] => 4
	 	[1] => 7
	 	[2] => 6
	 )
Example
	function get_group_id($userid)
	{	
		global $db;
		
		$group_ids = array();
      
		$result = $db->execute("
			SELECT group_id
			FROM " . TABLE_PREFIX . "user_group
			WHERE user_id = '" . $db->escape_string($userid) . "'
		");
      
		if ($result AND $db->count_select() > 0) 
		{	 
			while ($row = $db->fetch_array($result))
			{
				$group_ids[] = $row['group_id'];
			}
			 
			return $group_ids;
		}
		else
		{
			return NULL;
		}

		return NULL;
	}

Function: get_all_groups()

This is an optional function. You can customize it if you have groups to enable group permissions such as premium members having access to different features. It returns an array of all the group IDs and names that exist on your site.

Return Example
	Array
	(
		[0] => Array
		(
			[0] => 1
			[1] => "Administrators"
		)
		[1] => Array
		(
			[0] => 2
			[1] => "Users"
		)
	)
Example
	function get_all_groups()
	{	
		global $db;
		
		$groups = array();

		$result = $db->execute("
			SELECT group_id, group_name
			FROM " . TABLE_PREFIX . "groups
		");
		
		if ($result AND $db->count_select() > 0) 
		{	 
			while ($row = $db->fetch_array($result))
			{
				$groups[] = array($row['group_id'], $row['group_name']);
			}
			 
			return $groups;
		}
		else
		{
			return NULL;
		}
		
		return NULL;
	}

Remember to visit the debug page to help you through the custom installation processes by visiting http://www.yoursite.com/arrowchat/debug/ (replacing yoursite.com with your own domain).


Sometimes it may be necessary to place the ArrowChat header/footer code again such as when you update the theme on your site and your template files are replaced. Please use the guides and code below to get ArrowChat to show up again.

Header Code

Our header code below must be added directly after the <head> tag:

<link type="text/css" rel="stylesheet" id="arrowchat_css" media="all" href="/arrowchat/external.php?type=css" charset="utf-8" />
<script type="text/javascript" src="/arrowchat/includes/js/jquery.js"></script>
<script type="text/javascript" src="/arrowchat/includes/js/jquery-ui.js"></script>
Footer Code

Our footer code below must be added directly before the </body> tag:

<script type="text/javascript" src="/arrowchat/external.php?type=djs" charset="utf-8"></script>
<script type="text/javascript" src="/arrowchat/external.php?type=js" charset="utf-8"></script>

Integration Guides for Header/Footer Code
Select an integration using the selection box above.

Reinstall ArrowChat

If you need to reinstall ArrowChat for any reason, please follow the steps below.

  • Download ArrowChat

    Download the same version of ArrowChat that you want to reinstall from the member's area.

  • Upload and Overwrite Files

    Drag and drop the arrowchat folder onto your server in the same place as the existing folder. Make sure you choose to overwrite all the files if asked.

  • Run the Web Installer

    Visit http://www.yoursite.com/arrowchat/install/ in your browser (replacing yoursite.com with your own domain). The web installer will guide you through all the steps required to install ArrowChat.


Uninstall ArrowChat

If you need to uninstall ArrowChat for any reason, please follow the steps below.


  • Delete all the Files

    Simply use your preferred method of accessing your server files and delete the arrowchat folder.

  • Remove the Header/Footer Code

    Remove our header/footer code from your site's template. If you need instructions on how to find the code, please see our Header/Footer Code section.

  • Remove Database Tables (optional)

    This is an optional set as not doing this will not effect your site in any way. Use phpMyAdmin or your preferred method of database alteration to delete all the tables starting with arrowchat_.


Next