Friday, January 13, 2017

Add Remote Origin to local Git Repository


Steps to add local files to  new git repository


Step 1: Switch to your repository's directory

cd /path/to/your/repo

Step 2: Connect your existing repository to github

git init
git remote add origin https://kotturs@github.org/tech/tech.git
git pull origin master
git add
git commit -m "message"
git push origin master

Friday, December 23, 2016

Enable the MUC (Multi User Chat) in Prosody

Enabling Components in prosody server



In the XMPP world, many services are provided in components, which allows for greater ease of customization within a basic framework. A common example of this is the MUC or multi-user chat functionality. To enable MUC services in Prosody you need to add a line like the following to your
/etc/prosody/prosody.cfg.lua file.

/etc/prosody/prosody.cfg.lua

Component "conference.example.com" "muc"

In this example, conference.example.com is the domain where the MUC rooms are located, and will require an “DNS A record,” that points to the IP Address where the Prosody instance is running. MUCs will be identified as JIDs (Jabber IDs) at this hostname, so for instance the “rabbits” MUC hosted by this server would be located at rabbits@conference.example.com.

MUC, in contrast to many other common components in the XMPP world, is provided internally by Prosody. Other components, like transports to other services, run on an external interface. Each external component has its own host name, and provides a secret key which allows the central server to authenticate to it. See the following “aim.example.com” component as an example.

/etc/prosody/prosody.cfg.lua

Component "aim.example.com"
component_secret = "mysecretcomponentpassword"
Note that external components will need to be installed and configured independently of Prosody.

Typically, Prosody listens for connections from components on the localhost interface (i.e. on the 127.0.0.1 interface;). If you’re connected to external resources that are running on an alternate interface, specify the following variables as appropriate in the global section of the configuration file before the first VirtualHost declaration.

/etc/prosody/prosody.cfg.lua

component_interface = "192.168.0.10"
component_ports = { 8888, 8887 }

Using prosodyctl


The XMPP protocol supports “in-band” registration, where users can register for accounts with your server via the XMPP interface. However, this is often an undesirable function as it doesn’t permit the server administrator the ability to moderate the creation of new accounts and can lead to spam-related problems. As a result, Prosody has this functionality disabled by default. While you can enable in-band registration, we recommend using the prosodyctl interface at the terminal prompt.

If you’re familiar with the ejabberdctl interface from ejabberd, prosodyctl mimics its counterpart as much as possible.

To use prosodyctl to register a user, in this case username@example.com, issue the following command:


prosodyctl adduser username@example.com
To set the password for this account, issue the following command and enter the password as requested:


prosodyctl passwd username@example.com
To remove this user, issue the following command:

prosodyctl deluser username@example.com
Additionally, prosodyctl can provide a report on the status of the server in response to the following command:


prosodyctl status
Note that all of the prosodyctl commands require root privileges, unless you’ve logged in as the same user that Prosody runs under (not recommended).

Configure Prosody Server

The configuration file for Prosody is located in /etc/prosody/prosody.cfg.lua, and is written in Lua syntax.


Note that in the Lua programing language, comments (lines that are ignored by the interpreter) are preceded by two hyphen characters (e.g. --). The default config has some basic instructions in Lua syntax, which can be helpful if you’re unfamiliar with the language.

To allow Prosody to provide XMPP/jabber services for more than one domain, insert a line in the following form into the configuration file. This example defines three virtual hosts.

/etc/prosody/prosody.cfg.lua

VirtualHost "example.com"
VirtaulHost "example.com"
VirtualHost "staff.example.com"
VirtualHost "192.153.36.78"

Following a VirtualHost line there are generally a series of host-specific configuration options. If you want to set options for all hosts, add these options before the first VirtualHost declaration in your configuration file. For instance, to ensure that Prosody behaves like a proper Linux server daemon make sure that the posix; option is included in the modules_enabled = { } table.

/etc/prosody/prosody.cfg.lua

modules_enabled = {
                  -- [...]
                  "posix";
                  -- [...]
                  }
Note that there should be a number of global modules included in this table to provide basic functionality.

To disable a virtual host without removing it from your configuration file, add the following line to its section of the file:

/etc/prosody/prosody.cfg.lua
enabled = false

To specify administrators for your server, add a line in the following format to your prosody.cfg.lua file.

/etc/prosody/prosody.cfg.lua

admins = { "admin1@example.com"}
To add server-wide administrators, add entries to the admins section, as above, in the global section of the configuration file. To grant specific users more granular control to administer particular hosts, you can add an admins line, or more properly tables in Lua, to specific hosts.

If you need to enable the legacy SSL/TLS support, ensure that the following entry in the modules_enabled is enabled:

/etc/prosody/prosody.cfg.lua
modules_enabled = {
                  -- [...]
                  "legacyauth";
                  -- [...]
                  }

legacy_ssl_ports = { 5223 }
Do not forget to reload the configuration for the Prosody server after making any changes to your /etc/prosody/prosody.cfg.lua file, by issuing the following command:


/etc/init.d/prosody restart

Installing Prosody Server on Ubuntu

Install Prosody

Prosody

Prosody is a XMPP/Jabber server programmed in Lua that is simple and lightweight. Prosody uses fewer resources than its counterparts and is designed to be easy to configure and run. Ejabberd or OpenFire may be better suited for larger applications, but for most independent and small-scale uses Prosody is a more resource-efficient solution. Prosody is a very good candidate for running an XMPP server for a very small base of users, or for XMPP development.


Adding Software Repositories in ubuntu


The developers of Prosody provide software repositories for Debian and Ubuntu to more effectively distribute current versions of the software to users. In order to make these repositories accessible to your system we must append the following line to the /etc/apt/sources.list file:
/etc/apt/sources.list
deb http://packages.prosody.im/debian precise main

Now, to download the public key for the Prosody package repository, issue the following wget command. You may need to install wget first by running apt-get install wget. This will allow you to authenticate and verify packages:
wget http://prosody.im/files/prosody-debian-packages.key -O- | apt-key add -

Issue the following command to refresh the package database:
apt-get update
apt-get upgrade

Install Prosody


With the proper repository enabled, we’re now ready to install the Prosody server. Use the following command:

apt-get install prosody lua-sec-prosody

When apt finishes, the Prosody server will have been successfully installed (with support for TLS/SSL), and will be ready for configuration. Prosody provides an init script that allows you to reload the configuration file, start, stop, or restart the XMPP server. Issue one of the following commands as appropriate:
/etc/init.d/prosody reload
/etc/init.d/prosody start
 /etc/init.d/prosody stop
/etc/init.d/prosody restart

service prosody start
service prosody stop
service prosody restart

Tuesday, November 22, 2016

Codeigniter Transaction queries creation


Introduction on Transaction


A transaction is a logical unit of work that contains one or more SQL statements.
Transactions are atomic units of work that can be committed or rolled back.
When a transaction makes multiple changes to the database, either all the changes succeed
when the transaction is committed, or all the changes are undone when the transaction is rolled back.

A transaction begins with the first executable SQL statement.
A transaction ends when it is committed or rolled back, either explicitly
with a COMMIT or ROLLBACK statement or implicitly when a DDL (Data Definition Language (DDL) is used to manage table and index structure and CREATE, ALTER, RENAME, DROP and TRUNCATE statements are to name a few data definition elements) statement is issued.

Achieve the same in codeigniter using below code


$this->db->trans_begin();


//insert transaction
$i_data = array(
      'user_id'     => $app['opp_id']
    , 'amount'      => $app['total']
    , 'type'        => 1
    , 'feb_bal'     => 1
    , 'note'        => 'Earnings'
);

$this->db->insert('transaction', $i_data);
$tran_id = $this->db->insert_id();

//insert 2
$c_data = array(
      'oppt_opp_id' => $app['id']
    , 'status'      => 0 //closed
);
$this->db->insert('progress', $c_data);

//insert 3
$e_data = array(
      'tran_id' => $tran_id
    , 'app_id'  => $app['id']
    , 'type'    => 1
    , 'status'  => 2
);
$this->db->insert('earn_spend', $e_data);


if( if ($this->db->trans_status() === FALSE) {){
$this->db->trans_rollback();
}else{
  $this->db->trans_commit();
}

Note: To achieve the transaction statements all tables engine should be in innodb

How To Control WordPress User Permissions Effectively

To Get the access for external plugins such as AccessPress Social Share, Contact Db for a Wordpress Editor Role User

 we could get this feature by combining below plugins
1. Members Plugin : To create different Roles
2. Adminimize Plugin : To Disable Settings tab


Creating a new Role  Using Member Plugin


  • Enable the Member Plugin in Plugins tab
  • Under Users Tab > Click on the Add New Role link
  • Enter Role name text box
  • Grant the "manage_options" Capability to given role name
  • Save the Role
  • Create One user under this Role.

Member Plugin


To Disable the unwanted links under above created user, Need to follow the below steps


  • Enable the Adminimize Plugin in Plugins tab
  • Click the Adminimize Plugin settings link. (Tab Settings > Adminimize).
  • Under MiniMenu > Menu Option > check the settings tab related Url names.


Adminimize Plugin

Friday, November 18, 2016

Get magento session variable in php page

Mage::app('admin'); //get the admin session
Mage::getSingleton('core/session', array('name'=>'adminhtml')); //verify if the user is logged in to the backend
if(Mage::getSingleton('admin/session')->isLoggedIn()){
echo "logged in";
}else{
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
header('Location: '.$url."index.php/admin");
exit;
}