baig772 19 Web Application Architect

I am using passport in laravel for authenticating my users in APIs. I am able to authenticate different types of users from different tables and generating different token for them but the routes are not protected. For example.
A user can access the routes like this

Route::group(['middleware'  =>  'auth:api'], function () {
    Route::group(['prefix'  =>  'v1'], function () {

and A doctor can access the routes like

Route::group(['middleware'  =>  'auth:sellers'], function () {
    Route::group(['prefix'  =>  'v1'], function () {

but this middleware check doesn't seem to be working as I can access all the routes for sellers even if I have passed the token generated for api in Bearer header.

My config/auth.php looks like

'guards' => [
        'user' => [
            'driver' => 'session',
            'provider' => 'users',

        'seller' => [
            'driver' => 'passport',
            'provider' => 'sellers',

        'admin' => [
            'driver' => 'session',
            'provider' => 'admins',

        'web' => [
            'driver' => 'session',
            'provider' => 'users',

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
baig772 19 Web Application Architect

I am trying to implement multi authentication in laravel5.2. I am following this article

My Auth.php


return [
 'multi' => array(
   'user' => array(
     'driver' => 'eloquent',
     'model' => 'App\User',
     'table' => 'users',
   'admin' => array(
     'driver' => 'database',
     'model' => 'App\Admin',
     'table' => 'tbl_admin_user',
 'password' => [
 'email' => 'emails.password',
 'table' => 'password_resets',
 'expire' => 60,

My App.php

'providers' => [

         * Laravel Framework Service Providers...

         * Application Service Providers...


    | Class Aliases
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.

    'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        'Blade' => Illuminate\Support\Facades\Blade::class,
        'Cache' => Illuminate\Support\Facades\Cache::class,
        'Config' => Illuminate\Support\Facades\Config::class,
        'Cookie' => Illuminate\Support\Facades\Cookie::class,
        'Crypt' => Illuminate\Support\Facades\Crypt::class,
        'DB' => Illuminate\Support\Facades\DB::class,
        'Eloquent' => Illuminate\Database\Eloquent\Model::class,
        'Event' => Illuminate\Support\Facades\Event::class,
        'File' => Illuminate\Support\Facades\File::class,
        'Gate' => Illuminate\Support\Facades\Gate::class,
        'Hash' => Illuminate\Support\Facades\Hash::class,
        'Lang' => Illuminate\Support\Facades\Lang::class,
        'Log' => Illuminate\Support\Facades\Log::class,
        'Mail' => Illuminate\Support\Facades\Mail::class,
        'Password' => Illuminate\Support\Facades\Password::class,
        'Queue' => Illuminate\Support\Facades\Queue::class,
        'Redirect' => Illuminate\Support\Facades\Redirect::class,
        'Redis' => Illuminate\Support\Facades\Redis::class,
        'Request' => Illuminate\Support\Facades\Request::class,
        'Response' => Illuminate\Support\Facades\Response::class,
        'Route' => Illuminate\Support\Facades\Route::class,
        'Schema' => Illuminate\Support\Facades\Schema::class,
        'Session' => Illuminate\Support\Facades\Session::class,
        'Storage' => Illuminate\Support\Facades\Storage::class,
        'URL' => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View' => Illuminate\Support\Facades\View::class,



When ...

baig772 19 Web Application Architect

I have a string like
string(8234) "<style>.{ margin-bottom:10px; float:left; display: inline-block; width:56%; text-align:left; padding-right:20px; padding-left:20px; } . > p { display: table-cell; height: 150px; vertical-align: middle; }..................</style>.................
I want to remove <style> tag and all its contents.
I have tried

$description = $product_info['description']; // the string with style tag
$text = preg_replace('/<\s*style.+?<\s*\/\s*style.*?>/si', ' ', $description );
echo $text;

but it shows the same string without removing <style> tag.
I have also tried to replace only <style> tag by doing

$text    = str_replace("<style>", "", $description);

but this also doesn't work at all. I am seeing the same string again and again. I have also tried it with DOMParser

 $doc =   new DOMDocument();
 $xpath = new DOMXPath($doc);
 foreach ($xpath->query('//style') as $node) {
 $text    =    $doc->saveHTML();

but in all cases, output is the same with <style> and its contents

baig772 19 Web Application Architect

I have a div with width: 200px and I am adding text in it dynamically, I want the text to fit in this div but the text is getting out. I have tried to change the font size on character count but it does not work in all cases, like if string contains character with more width like W or M, the text goes out of the div.
Below is my code

if(cs >= 1 && cs <= 4) {
 if(this.engravingFontCaseSenstiveOptions(cText) == "Lower")
    }else if(this.engravingFontCaseSenstiveOptions(cText) == "Upper")
 else if(cs == 5) {
   if(this.engravingFontCaseSenstiveOptions(cText) == "Lower")
    }else if(this.engravingFontCaseSenstiveOptions(cText) == "Upper")
baig772 19 Web Application Architect

Problem I need an jax pagination in YII, The problems are

  • its not showing the required results for the first time. ie. it is showing the complete result
  • When clicked on more, it again shows the complete result below that section as it is

What Needed

  • i need to show, say 5 records for the first time
  • load the remaining results (5 rows) once clicked on more and so on
    My Wordkout


public function actionShopStoresByCategory($storecategory, $affusername = NULL) {

        $this->ticker_news = NewsTicker::model()->getTickerNews();
        if (!empty($affusername))
            $this->layout = "layout_home";
        $model = new Stores();
        $criteria = new CDbCriteria;
        $total = count($model->getAllStoresByCategory($storecategory));
        $pages = new CPagination($total);
        $pages->pageSize = 5;
        $posts = $model->getAllStoresByCategory($storecategory);
        $data['stores_cat_data'] = $posts;
        $data['store_id'] = $storecategory;
        $data['store_cat_name'] = Storescat::model()->findByPk($storecategory);

        $this->render('allstoresbycategory', array('model' => $model, 'data' => $data,'pages' => $pages,));


public function getAllStoresByCategory($category_id) {
    $connection = Yii::app()->db;
    if ($category_id == "22") {
    $sql = "SELECT DISTINCT s.title,s.cCommisions_percentage, s.url,, s.logo, s.publisher_id, cp.subid FROM stores s LEFT JOIN crawling_publisher cp ON WHERE 1 ORDER BY s.title ASC";
else {
        $sql = 'SELECT s.title, s.url,, s.logo, s.cCommisions_percentage, s.publisher_id, sc.store_category_id, cp.subid from stores s
            LEFT JOIN store_categories sc
            LEFT JOIN crawling_publisher cp
            where sc.store_category_id = \'' . $category_id . '\'
                                                            ORDER BY s.title ASC';
    $command = $connection->createCommand($sql);

    $data = $command->queryAll();

    if ($data) {
        return $data;
    } else {
        return false;


 if ($data['store_id'] != 22) {
 <div class="featuredcompaniesWrapp">
 <h1>Shop <?php echo $data['store_cat_name']->attributes['title']; ?> by Stores</h1>
 <!--featuredcompaniesRow--> ...
baig772 19 Web Application Architect

I have a form for editing a user record. Its updates the record for the first time but when i press the update button again, it shows me an empty screen and it unsets the picture as well. I cannot figure out what I am doign wrong Below is my code

public function actionEditProfile($affusername = NULL) {

        $this->layout = 'layout_home';

        if ($this->VarifyUser($affusername) && Yii::app()->user->id) {

            $model = new Users('edit'); //apply rules if user comes directly to signup page
            // uncomment the following code to enable ajax-based validation
            if (isset($_POST['ajax']) && $_POST['ajax'] === 'editprofile-form') {

            if (isset($_POST['Users'])) {

                $the_image = CUploadedFile::getInstance($model, 'image');
                if (is_object($the_image) && get_class($the_image) === 'CUploadedFile') {

                    $model->image = $the_image;

                if (is_object($the_image)) {

                    $file_name = Yii::app()->user->id . '.' . $model->image->extensionName;

                    $move    =   $model->image->saveAs(Yii::getPathOfAlias('webroot') . '/themes/myproject/images/users/' . $file_name);

                    $_POST['Users']['image'] = $file_name;

                $model->attributes = $_POST['Users'];

                if ($model->validate()) {

                    // form inputs are valid, do something here
                    if ($model->updateByPk(Yii::app()->user->id, $_POST['Users'])) {
                        //$this->setFlashSuccess("Unable to register user, please try again");
                        $this->setFlashSuccess('Updated successfully, now redirecting.');
                    } else {
                        $this->setFlashError("Unable to update user, please try again");
                        return false;
                } else {
                    echo 'validation  fail';

            $user_data = Users::model()->getUsersByUserName($affusername); //getting user information
            //$model=new Users('nonfb-create'); //apply rules if user comes directly to signup page
            $this->render('editprofile', array('model' => $model, 'data' => $user_data,));
        } else {

My view is

<div class="adminform_wrapp">
                $form = $this->beginWidget('CActiveForm', array(
                    'id' => 'editprofile-form',
                    'enableAjaxValidation' => false,
                    'clientOptions' => array(
                        'validateOnSubmit' => true,
                    'enableClientValidation' => true,
                    'focus' => array($model, 'first_name'), ...

Yes exactly @dani you got me right :)

But we still need to look into your code. May be there are some server settings isseu or some thing else

For pagination, this will help you Pagination

Paste your code here and let the community look whats wrong with that.
keep that in mind that "you cannot send emails from you local server unless and untill you have configured mercury"

2 questions in 1 question :p
There is no hard and fast rule for using the specific framework. But in my opinion, if you are a starter and you don't have experience in PHP, then you must start with Code Igniter

  • Strong Community
  • Extendable
  • Ease of use
  • Requires no confguration
    But still there is no hard and fast rule
    Go ahead :)
baig772 19 Web Application Architect

Hi all
I am making a website. I want to use linkshare on my website so that all the publishers registered with linkshare are listed on my website.
Any suggestions?
Link Share

Lolz. Yes I posted at the same time as i was in rush. Well it is solved now
Thanks :)

baig772 19 Web Application Architect

Any one ever wrked on live helper chat? This
This is following template structure may be symfony or smarty and I am looking to change some form labels, but cannot figure out where to chage?
Thanks in advance for help

What code should I show you? I know that we cannot create the page turn effect in php. I cannot use jQuery or other javascript techniques because this applies only on image but I have a file. This module is available for Joomla Click Here
I just want to know the functionality of this module so that I can create my own (if not available for custom php). Is there any way to convert pdf file pages into images?

baig772 19 Web Application Architect

Hi all
I have a website about magazines and I want to upload the pdf file into it and create a flipping book effect for that uploaded file. I have seen many softwares but he problem is

  • I want to integrate this functionality in my website
  • I am using custom Php, (I have seen module and components for Joomla and Magento)
    Thanks in advance

Thanks for the quick reply @Pritesh, but it did not work. It moved the magnifying glass image out of the search box (small in width). Nothing changed in with the search box (with greater width)

baig772 19 Web Application Architect

I have a search form with only one text field. The problem is that the width of that text field is not same. the style is

form#index-table-form input[type="text"] {
                            width: 106px;
                            height: 24px;
                            position: absolute;
                            outline: none;
                            right: 0;
                            top: 6px;
                            border: 1px solid #3772af;
                            padding-left: 6px;
                            padding-right: 24px;
                            font-family: Arial, Helvetica, sans-serif;
                            font-size: 14px;
                            font-weight: bold;
                            color: #0c4784;
                            background: white;
                            -moz-box-shadow: 0px 1px 2px 0px #737373;
                            -webkit-box-shadow: 0px 1px 2px 0px #737373;
                            box-shadow: 0px 1px 2px 0px #737373;
                            behavior: url("js/");

But the width and height is not the same on different pages. I cannot use the inline style or important to set the dimensions.

see the size of both text boxes is not same, though its a very minor difference

Please share what you get when you do

ehco "<pre>;
echo "</pre>";"
baig772 19 Web Application Architect

I am very new to wordpress. I am hivaing a small problem in my site. I am using a custom template for the home page, I have category filters on top, on mouseover it shows the total no. of models in that specific category. Well the problem is, I have done the pagination as asked in my previous qiestion but this category wise filter does not work with pagination. For example you bring the mouse over "0-12 Boys", it will show you 3 but when you click on that, it will bring only 1 (other 2 are on the next page)

Here is my site

Any help will be appreciated. Please let me know if I have to show you some of my theme codes etc. etc.

Thanks :)

@blocblue: I am using a custom theme, named as Ying_and_yang of onion eye. Now there is pagination but its returning the same results on each page :(

I am using a plugin wp_paginate

baig772 19 Web Application Architect

Its been alot of mess to make the pagination in wordpress :(
I have the pagination, but it renders the same page
template file is

?php get_header(); ?>

        global $my_query;
global $paged;
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$temp = $my_query;
$my_query = null;

$args  = array( 
    'post_type' => 'portfolio', 
    'paged' => $paged, 
    'posts_per_page' => 16, 
$my_query = new WP_Query( array( 'posts_per_page' => '-1', 'post_type' => 'portfolio' ) );
//do some work

//calling paginate
$wp_query = null; 
$wp_query = $temp;

paginate function is

function paginate($args = false) {

                    if ($this->type === 'comments' && !get_option('page_comments'))

            $r = wp_parse_args($args, $this->options);
            extract($r, EXTR_SKIP);

            if (!isset($page) && !isset($pages)) {

                            global $wp_query;
                            $wp_query->query('post_type=portfolio&posts_per_page=16&paged=' . $paged);
                if ($this->type === 'posts') {
                    $page = get_query_var('paged');
                    $posts_per_page = intval(get_query_var('posts_per_page'));
                    $pages = intval(ceil($wp_query->found_posts / $posts_per_page));
                else {
                    $page = get_query_var('cpage');
                    $comments_per_page = get_option('comments_per_page');
                    $pages = get_comment_pages_count();
                $page = !empty($page) ? intval($page) : 1;

            $prevlink = ($this->type === 'posts')
                ? esc_url(get_pagenum_link($page - 1))
                : get_comments_pagenum_link($page - 1);
            $nextlink = ($this->type === 'posts')
                ? esc_url(get_pagenum_link($page + 1))
                : get_comments_pagenum_link($page + 1);

            $output = stripslashes($before);
            if ($pages > 1) {
                $output .= sprintf('<ol class="wp-paginate%s">', ($this->type === 'posts') ? '' : ' wp-paginate-comments');
                $output .= sprintf('<li><span class="title">%s</span></li>', stripslashes($title));
                $ellipsis = "<li><span class='gap'>...</span></li>";

                if ($page > 1 && !empty($previouspage)) {
                    $output .= sprintf('<li><a href="%s" class="prev">%s</a></li>', $prevlink, stripslashes($previouspage));

                $min_links = $range * 2 + 1;
                $block_min = min($page - $range, $pages - $min_links);
                $block_high = max($page + $range, $min_links);
                $left_gap = (($block_min - $anchor - ...

why you are having same conditions in your else if's ??
It can be done by nested ifs. do another check in your ifs i.e. from which currency to what currency??

i am applying the highlighting on all over the text in which html tags are also there

have you created the object properly? i mean what is $dbc

baig772 19 Web Application Architect

I have a search form, in which a user enters a keyword and it displays the results with the keyword in description as highlighted text, for highlighting, i have used another class on that keyword. problem is that, if there is a keyword in some hyperlink or in some tag, it also applies that class there that causes the image load failure and links are not working.

That is how i am fetching my results and highlighting them if there is any keyword.

        $key = $_REQUEST['key'];
$sql = "select * from tbl_feed WHERE title LIKE '%$key%' OR description like '%$key%'";
$rs  = $dbFun->selectMultiRecords($sql);
        $title= mb_convert_encoding($rs[$j]['title'], "iso-8859-1","auto");
        $desc   = mb_convert_encoding($rs[$j]['description'],"iso-8859-1","auto");
      for($i = 0; $i < sizeof($arrKeywords); $i++){
                        $title = str_ireplace($arrKeywords[$i], "<font class=\"highlight\">" . $arrKeywords[$i] . "</font>", $title);
                        $desc = str_ireplace($arrKeywords[$i], "<font class=\"highlight\">" . $arrKeywords[$i] . "</font>", $desc);

<a href="<?=$rs[$j]['link']?>" target="_blank"><strong><?=$title?></strong></a><BR />
<?=$rs[$j]['pubdate']?><BR /><BR />
<?=$desc?><BR /><BR /><BR />
<? }

is there any way that it skips the html tags from replacing?

LPS: as you said, this is very easy to do but if I do this task in your way,


will be executed at least 4 times which may cause some performance problem and its also not a good practice to send connections to mysql every time?
I have read that in case of huge data, this practice can also lead to crash :( so i will not recomend any body to do that practice.
Hope i am clear now? :)

baig772 19 Web Application Architect

I have the following table structure of my db:

  • tbl_project

  • tbl_employee

  • tbl_deliverable

  • user_to_deliverable
    as tbl_prjct and tbl_deliverable has 1-many relation, tbl_employee and tbl_deliverable have many-many relation so they are splited into user_to_deliverable table

All i want is that a query to show project_name(from tbl_project), project's deliverables (from tbl_deliverable) and emloyee name to which that specific deliverable is assigned to.

Can i get help with this?

you can use the same as admin, you just have to check if it is commin gfrom admin, status will be 1 and if its from user, status will be 0