Tuesday, March 12, 2019

Solving Network Manangement Disabled in Ubuntu

go to /etc/NetworkManager/nm-system-settings.conf

then set managed=false to managed=true

sudo service network-manager restart
if there is no change try

touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
sudo service network-manager restart

Tuesday, January 15, 2019

PhpMyAdmin has no export as SQL option problem

Find the Export.php file in the phpmyadmin display folder or something like this phpMyAdmin/libraries/classes/Display depending on type of OS and package.

find the text /* Scan for plugins */ and put the code above right below after the text

if (isset($_GET['single_table'])) { 
$GLOBALS['single_table'] = $_GET['single_table']; 
}

Good luck

Sunday, January 13, 2019

Error: Your requirements could not be resolved to an installable set of packages of composer

Solve by putting ignoring platform requirements
Example: composer require --prefer-dist victor78/yii2-zipper:"~0.0.4"
You will get error 

Your requirements could not be resolved to an installable set of packages. Installation failed, reverting ./composer.json to its original content.
So can by as follows: 
composer require --prefer-dist victor78/yii2-zipper:"~0.0.4" --ignore-platform-reqs 




Wednesday, December 16, 2015

Yii2: Login With MySQL Database

1. Create a Table named Login

CREATE TABLE IF NOT EXISTS `login` (

  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(30) NOT NULL,
  `password` varchar(30) NOT NULL,
  `authKey` varchar(50) NOT NULL,
  `accessToken` varchar(50) NOT NULL,
  `role` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

2. Insert sample data into the table

INSERT INTO `yii2`.`login` (`id`, `username`, `password`, `authKey`, `accessToken`, `role`) VALUES (NULL, 'john', 'john1234', 'key1234567', 'token1234567', '1');

3. Create Model for the table. You may use Gii to generate the model

<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "login".
 *
 * @property integer $id
 * @property string $username
 * @property string $password
 * @property string $authKey
 * @property string $accessToken
 * @property integer $role
 */
class Login extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'login';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['username', 'password', 'authKey', 'accessToken', 'role'], 'required'],
            [['role'], 'integer'],
            [['username', 'password'], 'string', 'max' => 30],
            [['authKey', 'accessToken'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'username' => 'Username',
            'password' => 'Password',
            'authKey' => 'Auth Key',
            'accessToken' => 'Access Token',
            'role' => 'Role',
        ];
    }

}


4. Open User.php file in models/User.php. Goto to findIdentity static function

Original code

public static function findIdentity($id)
{
   return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
}

Change to

public static function findIdentity($id)
{
   $user = Login::findOne($id);
   if(count($user)){
      return new static($user);
   }
   return null;
}

5. Change static function findIdentityByAccessToken

Original Code

public static function findIdentityByAccessToken($token, $type = null)
{
        foreach (self::$users as $user) {
            if ($user['accessToken'] === $token) {
                return new static($user);
            }
        }

        return null;
}


Change to

public static function findIdentityByAccessToken($token, $type = null)
{
        $user = Login::find()->where(['accessToken'=>$token])->one();
        if(count($user)){
            return new static($user);
        }
        return null;
}

6. Change static function findByUsername

Original Code

public static function findByUsername($username)
{
        foreach (self::$users as $user) {
            if (strcasecmp($user['username'], $username) === 0) {
                return new static($user);
            }
        }

        return null;
}

Change to


public static function findByUsername($username)
{
        $user = Login::find()->where(['username'=>$username])->one();
        if(count($user)){
            return new static($user);
        }
        return null;
}



7. Now you can test the login page with test data.










Monday, June 3, 2013


Increase JQuery Mobile speed loading in Android using phoneGap or whatever




1) Put the JavaScript end of body befor </body>

2) Integrate the jquery function with phoneGap function for example in my code app is consuming JSON from a PHP server. I used

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
        $.getJSON("http://aamirkhan9876.byethost7.com/mobMoviesServer/services/m/get_banners.php",function(jData){//code});
}
onDeviceReady(); is provided by phoneGap.

3) Use splash screen instead of black screen because PhoneGap application takes time on startup. A black screen appears for few seconds. To avoide that use a splash screen.

On DroidGap Activity. use
        super.setIntegerProperty("splashscreen", R.drawable.images);
        super.loadUrl("file:///android_asset/www/index.html", 10000);  
 It will show the splash screen instead of black screen for 10000 ms.
 For activity loads before this time use blow code in index.html
 function onDeviceReady() {
      cordova.exec(null, null, "SplashScreen", "hide", []);
}
4) Make JavaScript and CSS External

5) Put Stylesheets at the Top

6) Avoid jquery mobile nvigation transition. If you can.
     $.mobile.defaultPageTransition="none"
7) Compress/Minify your js & css files. Use any Compressor such as yui compressor .

Monday, March 14, 2011

Installing PEAR on WAMP Windows

When you installed the WAMP search for the file "go-pear.bat". Normally the file is located in C:\wamp\bin\php\php5.3.5 but depending on version of WAMP. I'm now using WAMP 2.1e which supports PHP5.3.5. Go to the folder and run the file as administrator.

If you get this type of error, don't worry

phar "C:\wamp\bin\php\php5.3.5\PEAR\go-pear.phar" does not have a signaturePHP W
arning: require_once(phar://go-pear.phar/index.php): failed to open stream: pha
r error: invalid url or non-existent phar "phar://go-pear.phar/index.php" in C:\
wamp\bin\php\php5.3.5\PEAR\go-pear.phar on line 1236
PHP Stack trace:
PHP 1. {main}() C:\wamp\bin\php\php5.3.5\PEAR\go-pear.phar:0

Warning: require_once(phar://go-pear.phar/index.php): failed to open stream: pha
r error: invalid url or non-existent phar "phar://go-pear.phar/index.php" in C:\
wamp\bin\php\php5.3.5\PEAR\go-pear.phar on line 1236

Call Stack:
0.0117 717744 1. {main}() C:\wamp\bin\php\php5.3.5\PEAR\go-pear.phar:0


Press any key to continue . . .

Open Command prompt that go to the folder C:\wamp\bin\php\php5.3.5\PEAR and type "php -d phar.require_hash=0 go-pear.phar" . Make sure you have set the PHP Environment.

If you don't set the PHP environment, type "php -d phar.require_hash=0 PEAR\go-pear.phar" from the folder C:\wamp\bin\php\php5.3.5\

The just press ENTER to accept default setup.

Setting CakePHP on WAMP Server

Setting CakePHP on WAMP Server is very easy. Follow the following steps:-

  1. Configure Apache WAPM Server
  2. Open Apache httpd.conf configuration
  3. Search for #LoadModule rewrite_module modules/mod_rewrite.so
  4. Remove the "#" and the line becomes LoadModule rewrite_module modules/mod_rewrite.so
  5. Go to directory setting and make it Allow from all
  6. Open php.ini file then search for "curl" and remove the ";" to enable extension=php_curl.dll
  7. Restart the WAMP Server.