I'm using a Genesis LifeStyle Pro child theme.
URL: https://www.test.rainerklar.de/blog-fuer-verjuengung-und-gesundheit/
On my Blog-page that is showing all posts with an excerpt I see an Error-notice on top of the header:
Notice: Array to string conversion in /home/jungvita/public_html/test/wp-content/plugins/content-aware-sidebars/lib/wp-content-aware-engine/core.php on line 312
If I use the sidebar-plugin or not for this page this error is visible and needs a fix. The page should have the standard primary sidebar. I tried to work without the plugin for this page, and with the plugin by setting "posts" for the page-type, without anything else for definition.
Here is the code of line 312 and 313:
$data = "({$id}.meta_value IS NULL OR {$id}.meta_value IN ('".implode("','",$data) ."'))";
}
EDIT: With a debug-plugin I got this notice:
NOTICE: wp-content/plugins/content-aware-sidebars/lib/wp-content-aware- engine/core.php:312 - Array to string conversion
require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/lifestyle-pro/home.php'), genesis, get_header, locate_template, load_template, require_once('/themes/lifestyle-pro/header.php'), do_action('genesis_meta'), WP_Hook->do_action,WP_Hook->apply_filters, blog_page_genesis_meta, is_active_sidebar, wp_get_sidebars_widgets, apply_filters('sidebars_widgets'), WP_Hook->apply_filters, CAS_Sidebar_Manager->replace_sidebar, WPCACore::get_posts, WPCACore::get_conditions, implode
Maybe it helps?!
EDIT2: Here is the complete code of the section
// Return cache if present
of "core.php" (plugin):
// Return cache if present
if(isset(self::$condition_cache[$post_type])) {
return self::$condition_cache[$post_type];
}
$excluded = array();
$where = array();
$join = array();
$cache = array(
$post_type
);
$modules = self::$type_manager->get($post_type)->get_all();
foreach (self::$type_manager->get_all() as $key => $type) {
if($key == $post_type) {
continue;
}
if($type->get_all() === $modules) {
$cache[] = $key;
}
}
foreach ($modules as $module) {
$id = $module->get_id();
if(apply_filters("wpca/module/{$id}/in-context", $module->in_context())) {
$join[$id] = apply_filters("wpca/module/{$id}/db-join", $module->db_join());
$data = $module->get_context_data();
if(is_array($data)) {
$data = "({$id}.meta_value IS NULL OR {$id}.meta_value IN ('".implode("','",$data) ."'))";
}
$where[$id] = apply_filters("wpca/module/{$id}/db-where", $data);
} else {
$excluded[] = $module;
}
}
There are no line-numbers, so look for
if(is_array($data)) {
$data = "({$id}.meta_value IS NULL OR {$id}.meta_value IN ('".implode("','",$data) ."'))";
}
These lines are 311 to 313.
In this thread I found a solution:
Mit einem # kannst du normalerweise die Fehlermeldungen ausschalten
I did so putting the # just before 'implode':
$data = "({$id}.meta_value IS NULL OR {$id}.meta_value IN ('".#implode("','",$data) ."'))";
}
Now the notice is gone.
Related
It seems like Instagram has changed certain things, because I have tried several codes on my html website to show the amount of Instagram followers on a button, but nothing works.
I tried this:
<?php
$account='XXX';
$instagramsource=file_get_contents('https://instagram.com/' . $account);
preg_match_all('/"userInteractionCount":"(.*?)"/', $instagramsource, $count);
$followcount=$count[1][0];
echo "$account instagram account has $followcount followers";
?>
Also this
<?php
$otherPage = 'XXX';
$response = file_get_contents("https://www.instagram.com/$otherPage/?__a=1");
if ($response !== false) {
$data = json_decode($response, true);
if ($data !== null) {
$follows = $data['graphql']['user']['edge_follow']['count'];
$followedBy = $data['graphql']['user']['edge_followed_by']['count'];
echo $follows . ' and ' . $followedBy;
}
}
?>
And this ...
<?php
$url = "https://www.instagram.com/XXX";
$json = file_get_contents($url);
$obj = json_decode($json, true);
$content = $obj['query']['results']['script']['content'];
$content = str_replace("window._sharedData =", "", $content);
$content = str_replace(";", "", $content);
$content = trim($content);
$json = json_decode($content);
$instagram_follower_count = $json->entry_data->ProfilePage{0}->user->followed_by->count;
?>
And finally this:
<?php
$username = 'XXX';
$response = #file_get_contents( "https://www.instagram.com/$username/?__a=1" );
if ( $response !== false ) {
$data = json_decode( $response, true );
if ( $data !== null ) {
$follows = $data['graphql']['user']['edge_follow']['count'];
$followedBy = $data['graphql']['user']['edge_followed_by']['count'];
echo 'XXX follows:' . $follows . ' and is followed by: ' . $followedBy;
}
}
?>
None works.
Can anyone indicate what would work in 2021, please?
Thanks.
It's because the url https://www.instagram.com/$username/?__a=1 is redirecting to login page & giving u a html response
You can check it by echo $response
These posts will help you link1,link2
Instagram blocked access via __a=1 parameter since 2018-04-12. __a=1 must be replaced by JS and Ajax bypass. I've looked for an alternative solution. You can use javascript code inside php. For example:
async function instagramFollowers () {
const followers = []
try {
const userInfoSource = await Axios.get('https://www.instagram.com/123/')
const jsonObject = userInfoSource.data.match(/<script type="text\/javascript">window\._sharedData = (.*)<\/script>/)[1].slice(0, -1)
const userInfo = JSON.parse(jsonObject)
const mediaArray = userInfo.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges.splice(0, 10)
for (let media of mediaArray) {
const node = media.node
followers.push(node.thumbnail_src)
}
} catch (e) {
console.error('Unable to retrieve Followers. Reason: ' + e.toString())
}
return followers
}
Other helpful links: how to write javascript code inside php
https://code.tutsplus.com/tutorials/how-to-use-ajax-in-php-and-jquery--cms-32494
There is a fuvar_status field in my sql table. Now, the fullcalendar cells have a static color.
What i want is: if the fuvar_status is 0, the background will be #ff0000, or the fuvar_status is 1, the bg will be an another color.
How to write this in the, and javascript file?
My php, that gets the records from sql:
<?php
include_once("connect.php");
$sql =
"
SELECT
fuvar.fuvar_id,
fuvar.fuvar_date,
fuvar.fuvar_status,
fuvar.fuvar_kerulet,
gyarto.gyarto_nev,
Varosok.VarosNev
FROM fuvar
LEFT JOIN gyarto ON fuvar.fuvar_honnan = gyarto.gyarto_id
LEFT JOIN Varosok ON fuvar.fuvar_hova = Varosok.VarosID
LIMIT 50
";
// WHERE status != Lezárt fuvar
$get = mysqli_query($kapcs, $sql) or die("SQL ERROR 1 - " . mysqli_error($kapcs));
if(mysqli_num_rows($get) > 0 )
{
$VarosNev = array();
$gyarto_nev = array();
$fuvar_date = array();
$fuvar_id = array();
while( $e = mysqli_fetch_array($get))
{
if($e['fuvar_kerulet'] == "0" ) { $VarosNev[] = $e['VarosNev']; }
else { $VarosNev[] = $e['VarosNev'] .' '. $e['fuvar_kerulet']; }
$gyarto_nev[] = $e['gyarto_nev'];
$fuvar_date[] = $e['fuvar_date'];
$fuvar_id[] = $e['fuvar_id'];
}
$res = array
(
'VarosNev' => $VarosNev,
'gyarto_nev' => $gyarto_nev,
'fuvar_date' => $fuvar_date,
'fuvar_id' => $fuvar_id,
);
echo json_encode($res);
}
?>
Javascript, generate events:
for (i = 0; i < hossz; i++)
{
if (eventArray.fuvar_id[i] != '')
{
valami.push({
title: eventArray.gyarto_nev[i] +'\n'+eventArray.VarosNev[i],
backgroundColor: '#03674e',
start: eventArray.fuvar_date[i],
url: '/fuvar-szerkesztes/' + eventArray.fuvar_id[i]
});
}
else
{
valami.push({
title: eventArray.gyarto_nev[i] +'\n'+eventArray.VarosNev[i],
backgroundColor: '#03674e',
start: eventArray.fuvar_date[i],
});
}
}
There seems to be no particular reason to do half of your processing in PHP and half in JavaScript. You could just make what PHP produces compatible with fullCalendar. You've also using a bizarre arrangement of redundant parallel arrays in PHP, and then relying on the index values to match the values up. Perhaps you aren't aware of PHP's support for associative arrays? You can do it all with one array to create actual events, directly:
$get = mysqli_query($kapcs, $sql) or die("SQL ERROR 1 - " . mysqli_error($kapcs));
if(mysqli_num_rows($get) > 0 )
{
$events = array();
while( $e = mysqli_fetch_array($get))
{
$VarosNev = ($e['fuvar_kerulet'] == "0" ? $e['VarosNev'] : $e['fuvar_kerulet']);
$evt = array(
"title" => $e['gyarto_nev']."\n".$VarosNev,
"backgroundColor" => ($e["fuvar_status"] == 0 ? "#ff0000" : "#03674e"),
"start": $e["fuvar_date"]
);
if ($e['fuvar_id'] != "") { $evt["url"] = "/fuvar-szerkesztes/".$e["fuvar_id"]; }
$events[] = $evt;
}
echo json_encode($events);
}
Then you shouldn't need the for loop in JavaScript at all - you can just send the JSON from the server direct into fullCalendar.
N.B. Obviously I could not test this fully without your data, so apologies for any small errors - point them out if you can't fix them and I will amend the answer if necessary.
I am getting following error in JS:
SyntaxError: Unexpected token < in JSON at position 0
How can I properly send HTML code (it's a whole page) through the JSON.
I did not made this idea, but this is the plugin that I am trying to install, and I am getting this error. So if anybody can point me out what is wrong in here and how to fix it, it would be great. Thanks.
public function ajaxfilter()
{
$this->registry->set('bf_force_tmp_table_creation', true);
$data = $this->_prepareFilterInitialData();
$json = array();
$route = $this->_getRequestParam('curRoute');
if ($route && $this->_getRequestParam('withContent')) {
$this->request->get['route'] = $route;
$this->load->controller($route, $data);
$json['products'] = $this->response->getOutput();
}
$this->load->model('module/brainyfilter');
$model = new ModelModuleBrainyFilter($this->registry);
$model->setData($data);
if ((bool)$this->_getRequestParam('count', false)) {
$json['brainyfilter'] = $model->calculateTotals();
}
if ((bool)$this->_getRequestParam('price', false)) {
$minMax = $model->getMinMaxCategoryPrice();
$min = floor($this->currency->format($minMax['min'], $this->_currency, '', false));
$max = ceil($this->currency->format($minMax['max'], $this->_currency, '', false));
$json['min'] = $min;
$json['max'] = $max;
}
$this->log->debug($json);
$isMijoShop = class_exists('MijoShop') && defined('JPATH_MIJOSHOP_OC');
if ($isMijoShop) {
header('Content-Type: application/json');
die(json_encode($json));
} else {
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}
Use json_encode to get a valid JSON string.
You can encode any scalar value, arrays and stdClass instances. For any other class, you may implement the JsonSerializable interface.
A simple HTML example:
<?php
$html = '<div class="container">What-Ever-Content </div>";
echo json_encode($html);
This will produce this output:
"<div class=\"container\">What-Ever-Content </div>"
I've searched the web for days but can't find a solution. I upgraded Magento from 1.5 to 1.9 and everything works fine. Except the checkout. On the last step it gets stuck every single time on "submitting order information".
System log says the following (but a minute before the error occurs. In the stuck position I don't get any error)
2016-08-07T22:23:16+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] /var/www/html/app/code/core/Mage/Core/Controller/Response/Http.php:52
[1] /var/www/html/lib/Zend/Controller/Response/Abstract.php:768
[2] /var/www/html/app/code/core/Mage/Core/Controller/Response/Http.php:84
[3] /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php:184
[4] /var/www/html/app/code/core/Mage/Core/Model/App.php:365
[5] /var/www/html/app/Mage.php:684
[6] /var/www/html/index.php:83</pre>
Console on the checkout site:
VK. Startup (background is ready)
prototype.js:5557 Uncaught TypeError: Cannot read property 'get' of undefined_createResponder # prototype.js:5557observe # prototype.js:5636(anonymous function) # (index):896
prototype.js:5557 Uncaught TypeError: Cannot read property 'get' of undefined_createResponder # prototype.js:5557observe # prototype.js:5636(anonymous function) # (index):1033
(index):1 Mixed Content: The page at 'https://www.owndomain.com/checkout/onepage/' was loaded over HTTPS, but requested an insecure script 'http://www.googleadservices.com/pagead/conversion.js'. This request has been blocked; the content must be served over HTTPS.
content.js:37 UA. Wait for background...
Does anybody have an additional idea? I have edited all template files with the formkey tag.
Edit:
The code of the found file:
if (empty ($_POST)) {
header("Location: " . $_SESSION['back_url']);
$this->_redirect(str_replace(Mage::getBaseUrl(), '', $_SESSION['back_url']));
}
$formData = $this->getRequest()->getPost('super_attribute');
$product_id = $this->getRequest()->getPost('pro_id');
$options = $this->getRequest()->getPost('options');
$params = $this->getRequest()->getParams();
//mage::log($params);
$url = $this->getRequest()->getPost('url');
$qty = $this->getRequest()->getPost('qty');
$type = $this->getRequest()->getPost('type');
if (!isset($qty))
$qty = 1;
if (isset($product_id)) {
try {
$request = Mage::app()->getRequest();
$product = Mage::getModel('catalog/product')->load($product_id);
$session = Mage::getSingleton('core/session', array('name' => 'frontend'));
$cart = Mage::helper('checkout/cart')->getCart();
/*
if (isset($formData)){
$arr = array(
'qty' => $qty,
'super_attribute' => $formData,
'options' => $options
);
$cart->addProduct($product, $arr);}
else
$cart->addProduct($product, $qty);
*/
$cart->addProduct($product, $params);
$session->setLastAddedProductId($product->getId());
$session->setCartWasUpdated(true);
$cart->save();
$_cart = Mage::helper('checkout/cart')->getCart();
$_cartcount = 0;
$_cartsubtotal = 0;
$items = $_cart->getItems();
$_SESSION['back_url'] = $url;
$result = $this->getLayout()->createBlock('checkout/cart_sidebar')->setTemplate('ajaxcart/cart/sidebar.phtml')
->addItemRender('simple', 'checkout/cart_item_renderer', 'checkout/cart/sidebar/default.phtml')
->addItemRender('configurable', 'checkout/cart_item_renderer_configurable', 'checkout/cart/sidebar/default.phtml')
->addItemRender('grouped', 'checkout/cart_item_renderer_grouped', 'checkout/cart/sidebar/default.phtml')
->toHtml();
echo $result;
} catch (Exception $e) {
echo 1;
}
} else {
echo 0;
Best,
IT0055
I'm in trouble with search.php file of sphider website indexing and search script. I need your help.
Actually i want to put sphider search script in my website to search the pages with keywords. But i have a problem. i have attached a search box in each page of website and now i want to put search.php file of sphider in form action. But when i checked i got that it don;t search results but beside it shows a search box in search.php file and when i enter any keyword and hit enter then it shows the results. So my question is. How to remove this search box from this search.php file and only get the search result.
' search.php?query= [---Here comes the search keywords entered in box--] &search=1'
this is URL that shows after hitting enter from search.php search box but when putting all details right in my page search engine it doesn't do anything and only ask to search through that box... So guys please help me....
<?php
/*******************************************
* Sphider Version 1.3.x
* This program is licensed under the GNU GPL.
* By Ando Saabas ando(a t)cs.ioc.ee
********************************************/
//error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
error_reporting(E_ALL);
$include_dir = "./include";
include ("$include_dir/commonfuncs.php");
//extract(getHttpVars());
if (isset($_GET['query']))
$query = $_GET['query'];
if (isset($_GET['search']))
$search = $_GET['search'];
if (isset($_GET['domain']))
$domain = $_GET['domain'];
if (isset($_GET['type']))
$type = $_GET['type'];
if (isset($_GET['catid']))
$catid = $_GET['catid'];
if (isset($_GET['category']))
$category = $_GET['category'];
if (isset($_GET['results']))
$results = $_GET['results'];
if (isset($_GET['start']))
$start = $_GET['start'];
if (isset($_GET['adv']))
$adv = $_GET['adv'];
$include_dir = "./include";
$template_dir = "./templates";
$settings_dir = "./settings";
$language_dir = "./languages";
require_once("$settings_dir/database.php");
require_once("$language_dir/en-language.php");
require_once("$include_dir/searchfuncs.php");
require_once("$include_dir/categoryfuncs.php");
include "$settings_dir/conf.php";
include "$template_dir/$template/header.html";
include "$language_dir/$language-language.php";
if ($type != "or" && $type != "and" && $type != "phrase") {
$type = "and";
}
if (preg_match("/[^a-z0-9-.]+/", $domain)) {
$domain="";
}
if ($results != "") {
$results_per_page = $results;
}
if (get_magic_quotes_gpc()==1) {
$query = stripslashes($query);
}
if (!is_numeric($catid)) {
$catid = "";
}
if (!is_numeric($category)) {
$category = "";
}
if ($catid && is_numeric($catid)) {
$tpl_['category'] = sql_fetch_all('SELECT category FROM '.$mysql_table_prefix.'categories WHERE category_id='.(int)$_REQUEST['catid']);
}
$count_level0 = sql_fetch_all('SELECT count(*) FROM '.$mysql_table_prefix.'categories WHERE parent_num=0');
$has_categories = 0;
if ($count_level0) {
$has_categories = $count_level0[0][0];
}
require_once("$template_dir/$template/search_form.html");
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function poweredby () {
global $sph_messages;
//If you want to remove this, please donate to the project at http://www.sphider.eu/donate.php
print $sph_messages['Powered by'];?> <img src="sphider-logo.png" border="0" style="vertical-align: middle" alt="Sphider">
<?php
}
function saveToLog ($query, $elapsed, $results) {
global $mysql_table_prefix;
if ($results =="") {
$results = 0;
}
$query = "insert into ".$mysql_table_prefix."query_log (query, time, elapsed, results) values ('$query', now(), '$elapsed', '$results')";
mysql_query($query);
echo mysql_error();
}
switch ($search) {
case 1:
if (!isset($results)) {
$results = "";
}
$search_results = get_search_results($query, $start, $category, $type, $results, $domain);
require("$template_dir/$template/search_results.html");
break;
default:
if ($show_categories) {
if ($_REQUEST['catid'] && is_numeric($catid)) {
$cat_info = get_category_info($catid);
} else {
$cat_info = get_categories_view();
}
require("$template_dir/$template/categories.html");
}
break;
}
include "$template_dir/$template/footer.html";
?>
//*
I have removed
require_once("$template_dir/$template/search_form.html");
and checked whether it work. But no it didn't work. So i'm getting frustrated..
Somebody please help me..
Take a look at this line:
$search_results = get_search_results($query, $start, $category, $type, $results, $domain);
This is a function being called from a file that is included above searchfuncs.php I you want to use the Sphider search functionality with your own search bar do the following (assuming MVC pattern is used):
Include searchfunc.php in your controller for your searchbar
Format your keywords from the searchbar to fit conventions for Sphider and prepare the required parameters for step #3
Call the get_search_results() function from your custom controller
Now that you are getting results you may want to create a custom view to handle the search results, or else refer back to sphider/templates/standard/search_results.html for the required HTML for default Sphider results.