#StackBounty: #php #http-redirect #google-index Should i header 301 for this redirection and how will google index be influenced?

Bounty: 50

I have an application that when you go to http://website.com it automatically redirects to http://website.com/en since no language was detected.

Is it neccesary to use a redirect 301 for this redirection? What about for google indexing? Will my google indexing be affected by this redirection?


Get this bounty!!!

#StackBounty: #php #mysql #database #rest #codeigniter Create API endpoint for fetching dynamic data based on time

Bounty: 50

I have a scraper which periodically scrapes articles from news sites and stores them in a database [MYSQL].
The way the scraping works is that the oldest articles are scraped first and then i move onto much more recent articles.

For example an article that was written on the 1st of Jan would be scraped first and given an ID 1 and an article that was scraped on the 2nd of Jan would have an ID 2.

So the recent articles would have a higher id as compared to older articles.

There are multiple scrapers running at the same time.

Now i need an endpoint which i can query based on timestamp of the articles and i also have a limit of 10 articles on each fetch.

The problem arises for example when there are 20 articles which were posted with a timestamp of 1499241705 and when i query the endpoint with a timestamp of 1499241705 a check is made to give me all articles that is >=1499241705 in which case i would always get the same 10 articles each time,changing the condition to a > would mean i skip out on the articles from 11-20. Adding another where clause to check on id is unsuccessful because articles may not always be inserted in the correct date order as the scraper is running concurrently.

Is there a way i can query this end point so i can always get consistent data from it with the latest articles coming first and then the older articles.

EDIT:

   +-----------------------+
   |   id | unix_timestamp |
   +-----------------------+
   |    1 |   1000         |
   |    2 |   1001         |
   |    3 |   1002         |
   |    4 |   1003         |
   |   11 |   1000         |
   |   12 |   1001         |
   |   13 |   1002         |
   |   14 |   1003         |
   +-----------------------+

The last timestamp and ID is being sent through the WHERE clause.

E.g.
$this->db->where('unix_timestamp <=', $timestamp);
$this->db->where('id <', $offset);
$this->db->order_by('unix_timestamp ', 'DESC');
$this->db->order_by('id', 'DESC');

On querying with a timestamp of 1003, ids 14 and 4 are fetched. But then during the next call, id 4 would be the offset thereby not fetching id 13 and only fetching id 3 the next time around.So data would be missing .


Get this bounty!!!

#StackBounty: #php #url-rewriting Rewrite sub folder dynamically with country code in WordPress using PHP

Bounty: 50

I know this question has been asked so many times but I didn’t find any working solution or example which I can use to fix my problem.

I have been working on a client site. There are two similar sites, one for their own country and second for other countries visitors.

Their main site hosted in the root of server and second site hosted in the sub folder.

Now what I want is dynamic url rewrite for second site which is hosted into sub folder with the country code of the visiting user.

For e.g.

http://example.com

http://example.com/subfolder/

are the urls.

I want this http://example.com/subfolder/ to be changed into this http://example.com/country_code/ where country_code is visitor country code in ISO format getting through php function.

So if user is from United States the subfolder must be changed into us, the new url should be now http://example.com/us/.

I want this to work for all type of pages, whether its a page, post, category, tag or author page.

So again, http://example.com/subfolder/any-type-of-url/ => http://example.com/country_code/any-type-of-url/

Remember country_code is user/visitor country code in ISO format.

Let me know if someone needs more information on this. Thanks in Advance.

PS: I tried to achieve this using add_rewrite_rule() function available in WP.


Get this bounty!!!

#StackBounty: #php #apache-2.4 #.htaccess #httpd #php.ini php_value overrides with Apache using a front controller

Bounty: 50

I am trying to set specific server side value for virtual paths used to upload files.

All my URLs are virtual and requested are dispatched by a front controller. I have the following config in my site’s only .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^ index.php [L]
</IfModule>

Since upload_max_filesize cannot be set with ini_set, I need to used either .htaccess files or Apache .conf to overrides this setting.

Considering I do not have real files/folders to put .htaccess, I presume the only way is to use Apache .conf.

I tried several ways to make it way using either <LocationMatch>, <Location> and even <FilesMatch> but cannot figure out how to make it work.

Here is how my site’s vhost.conf look like:

<LocationMatch "upload">
    php_value upload_max_filesize    60M
</LocationMatch>

<Directory "/mysite/documentroot">
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

My theory is that since my site is using a single FrontController that that the <Location> rule is applied after the redirect, it’s impossible to do this from an Apache side.

Unless I missed something, the best way to solve this would be to request a feature change on the PHP side to allow changing these settings using ini_set?


Get this bounty!!!

#StackBounty: #php #laravel #laravel-socialite Socialite laravel 5.4 Facebook login error (ClientException in RequestException.php line…

Bounty: 50

in past signup with Facebook functionality working fine suddenly when i signup or Login with facebook then i am facing this error

ClientException in RequestException.php line 111: Client error: GET
https://graph.facebook.com/v2.8/me?access_token=&fields=name,email,gender,verified,link&appsecret_proof=5fbda0d218f94cb8024712269c053f0186d360efd82cd358b588eaf621e0c79c
resulted in a 400 Bad Request response: {“error”:{“message”:”An active
access token must be used to query information about the current
user.”,”type”:”OAuthExce (truncated…)

i am using Socialite Package

Note: For some reasons i can’t update composer or complete socialite package

Note: i had some changes in socialite packages for some purpose. if i update whole package then previous changes will be affect.. i did some changes in LinkedInProvider and GoogleProvider files.. i need proper solution for this error

My project is live and users facing this problem. any help will be appreciate..


Get this bounty!!!

#StackBounty: #php #javascript #theme-customizer #settings WordPress customizer: load controls in a custom div

Bounty: 100

I have a custom div (holder for extra settings) which I need to load some specific controls from a specific section in there. I can get the controls in JavaScript but I can’t generate the necessary HTML as WordPress do in sections.

wp.customize.section( 'custom_div_1' ).controls();

It gives an array of controls but how to generate the HTML like Site title or Tagline controls in default WordPress section.

This custom div will toggle by the left button Open extra settings.

Screenshot for easier understanding:screenshot

Any help is appreciated.


Get this bounty!!!

#StackBounty: #php #image #math #imagemagick #sequence Determine tile size sequnce

Bounty: 50

please help, i am stuck very seriously, i have following tile values:

$tileheight = "58"; // 100x100  104px   560x560
$tileheight = "36"; // 200x200  104px   560x560
$tileheight = "32"; // 300x300  104px   560х560
$tileheight = "30"; // 400x400  104px   560х560

100×100…400×400 – height and width of generated image inside tile

104px – height of tile

560×560 – height and width that will always outputs (fits in image)

What would be the value – “?” for dimension 500×500? What formula could i use?

$tileheight = "?"; // 500x500 104px   560х560

Here for what result will outputs for 400×400:
400x400

UPDATE:

Here what code i use for conversion:

exec("convert '$image' -resize ".$imgw."x".$imgh."! -quality 100 'proc/res$session.jpg'");

exec("convert '$tile' -resize x".$tileheight." -quality 100 'proc/til$session.jpg'");

exec("convert $image $pp -write mpr:image +delete 
proc/til$session.jpg -write mpr:edge_top +delete 
proc/til$session.jpg -write mpr:edge_btm +delete 

mpr:image -alpha set -bordercolor none 
-compose Dst -frame ".$tileheight."x".$tileheight."+".$tileheight." -compose over 

-transverse  -tile mpr:edge_btm 
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' 
-transverse  -tile mpr:edge_top 
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' 

mpr:image -gravity center -composite proc/ok$session.jpg");

$input = "proc/ok$session.jpg";
$toWidth  = "840";
$toHeight = "560";
$quality  = "100";
// -background white -gravity center -extent {$toWidth}x{$toHeight}
exec("convert $input -thumbnail {$toWidth}x{$toHeight} proc/ok$session.jpg");

Here what formula i use to make correct tile height:

$tiledata = getimagesize($tile);

$tilewidth = $tiledata[0];
$tileheight = $tiledata[1];

$math1 = ($tileheight+$tileheight)/($imgw+$imgh);
$tileheight = $tileheight * $math1;


Get this bounty!!!

#StackBounty: #php #wordpress #wpml Unable to translate one custom post type slug in WPML

Bounty: 50

I have raised this issue on the WPML forums, but hoping someone here will be able to assist.

I am trying to translate the slug for a custom post type

The English URL is http://brigade-electronics.com/nl/products/backeye360/

The translated URL should be http://brigade-electronics.com/nl/producten/backeye360/

Instead I get a 404 error when navigating to the URL after enabling the translate slug option

Steps to duplicate the issue:

  • Click On WPML -> Translation options
  • Enable the Translate custom posts slugs (via WPML String Translation).
  • Under the Custom posts settings (on the same page) Click the translate checkbox
  • Added the translated slug for each language
  • Hit save
  • Navigate to the front end and see a 404 error on the products section only.

I have run all options in the troubleshooting page, to clear up the database.

This only seems to apply to certain pages within the product section. The weirdest part of this is the Canadian section of the site, as the term ‘product’ is in English therefore the URLs remain the same with or without the translated slugs in place, however, I still get the 404 error on these pages.

It is also worth noting that all other custom post types work without issue.

The custom post types have been registered in the standard way

function register_products_post_type() {

    $labels = array(
        'name' => __( 'Products', '' ),
        'singular_name' => __( 'Product', '' )
    );

    $args = array(
        'label' => __( 'Products', '' ),
        'labels' => $labels,
        'description' => '',
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_rest' => false,
        'rest_base' => '',
        'has_archive' => false,
        'show_in_menu' => true,
        'exclude_from_search' => false,
        'capability_type' => 'post',
        'map_meta_cap' => true,
        'hierarchical' => true,
        'rewrite' => array( 'slug' => 'products', 'with_front' => false ),
        'query_var' => true,
        'menu_position' => 6,
        'menu_icon' => 'dashicons-cart',
        'supports' => array( 'title', 'thumbnail', 'page-attributes' )
    );

    register_post_type( 'products', $args );

}
add_action( 'init', 'register_products_post_type' );

Thanks


Get this bounty!!!

#StackBounty: #php #filter #laravel-4 #model How to filter all quires result in laravel 4.2 app by year

Bounty: 50

I want to add filter for all application quires to get result by specific year

I put current year on session

for example :

public function postLogin()
{
    Session::put('currentYear', date("Y"));
}

and I have many controllers on my app now I want any model query result filter by session year => Session::get(‘currentYear’)

I have a lot of models for example I have one route to view all users, teachers , students`

public function getList()
{
    $data['students'] = User::where('group_id', '=', 4)->get();

    return View::make('students.list', $data);
}

Can I put __construct in BaseControler to filter all app quires by Session::get(‘currentYear’)?


Get this bounty!!!

#StackBounty: #php #apache #caching #xampp How to disable Apache caching in Apache-XAMPP?

Bounty: 50

I am having this weird problem with my XAMPP-Apache.
I am making an log-in system where form is posted to redirect.php page.
I updated the redirect.php and but still it is showing me the same old result.
There is not even a single line to redirect(header fn call) it to another page but still it redirects to home.php page as it was doing in older script.
I tried clearing cache of my browser and changing the browser for testing but didn’t work…I even tried rebooting the server but no change.
Please help me through….


Get this bounty!!!