include function and Graphs in PHP - graph

i am using libCharts in my PHP application ....the graphs are working but when i include it in the application using INCLUDE function then it does not work
it give me the error
Warning: include(charts/charts-example-line.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\MyProject\index.php on line 349
Warning: include() [function.include]: Failed opening 'charts/charts-example-line.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\MyProject\index.php on line 349
My Graph code is
$chart = new PieChart(500, 250);
$dataSet = new XYDataSet();
$dataSet->addPoint(new Point("Mozilla Firefox (80)", 1000));
$dataSet->addPoint(new Point("Konqueror (75)", 75));
$dataSet->addPoint(new Point("Other (50)", 50));
$chart->setDataSet($dataSet);
$chart->setTitle("User agents for www.example.com");
$chart->render("libchart/demo/generated/demo1.png");
?>
<html>
<body>
<img src="libchart/demo/generated/demo789.png" border=0 />
</body>
</html>
please help me

There's nothing wrong with your graph code. Rather, the libCharts files are not able to be found by PHP, because the directory they are in is not in the "include_path" lists of paths that PHP will search.
You might want to read these PHP manual pages:
http://php.net/manual/en/ini.core.php#ini.include-path
http://php.net/manual/en/function.set-include-path.php
http://php.net/manual/en/function.include.php

Related

file_get_html() not working for the only webpage

I want to call a simple DOM file
I tested with another links and it works, but with this url it's not working.
My code is:
$bnadatos = file_get_html("http://www.rofex.com.ar/cem/FyO.aspx");
foreach($bnadatos->find('[#id="ctl00_ContentPlaceHolder1_gvFyO"]') as $i){
echo "datos:";
echo $i->innertext;
}
Response is a blank page.
What's wrong?
i solved with
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$response = file_get_html("https://www.rofex.com.ar/cem/FyO.aspx", false, stream_context_create($arrContextOptions));
foreach($response->find('[#id="ctl00_gvwDDF"]/tbody/tr[2]/td[2]') as $i){
echo $i->innertext;
}
thank you #maio290 for light my road
This is just a guess, but do you have your error reporting on?
Out of the box, this is not working with the simple-html-dom library:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /var/www/html/dom.php on line 83
Warning: file_get_contents(): Failed to enable crypto in /var/www/html/dom.php on line 83
Warning: file_get_contents(http://www.rofex.com.ar/cem/FyO.aspx): failed to open stream: operation failed in /var/www/html/dom.php on line 83
Fatal error: Call to a member function find() on boolean in /var/www/html/test.php on line 11
A fix for this can be found here - with that in place, I still get a blank page, which is due to a wrong answer (301 Moved Permanently) - for this to fix, you need to modify
'follow_location' => false
to
'follow_location' => true
so, now we get the proper site content - you can modify the selector to $html->find('#ctl00_ContentPlaceHolder1_gvFyO'); this will find all element which id=ctl00_ContentPlaceHolder1_gvFyO - see the documentation as reference.

OpenFOAM: FOAM FATAL ERROR: Unknown TurbulenceModel type RASModel

I'm trying to follow this OpenFOAM tutorial for using Gmsh to generate Axisymmetric mesh. The files are provided here. However when I try to solve the problem using the pimpleFoam solver I get the error:
--> FOAM FATAL ERROR:
Unknown TurbulenceModel type RASModel
Valid TurbulenceModel types:
3
(
LES
RAS
laminar
)
From function static Foam::autoPtr > Foam::TurbulenceModel::New(const alphaField&, const rhoField&, const volVecto rField&, const surfaceScalarField&, const surfaceScalarField&, const transportMo del&, const Foam::word&) [with Alpha = Foam::geometricOneField; Rho = Foam::geom etricOneField; BasicTurbulenceModel = Foam::incompressibleTurbulenceModel; Trans portModel = Foam::transportModel; Foam::TurbulenceModel::alphaField = Foam::geometricOneField; Foam::Turbulenc eModel::rhoField = Foam::geome tricOneField; Foam::volVectorField = Foam::GeometricField; Foam::surfaceScalarField = Foam::GeometricFi eld; Foam::TurbulenceModel::transportModel = Foam::transportMo del]
in file /opt/CFDSupportFOAM4.0/beta/OpenFOAM-dev/src/TurbulenceModels/turbul enceModels/lnInclude/TurbulenceModel.C at line 113.
As explained in this page apparently the syntax of turbulenceProperties in case/constant has changed. So I edited the turbulenceProperties file from:
simulationType RASModel;
to
simulationType RAS;
RAS
{
RASModel kEpsilon;
turbulence on;
printCoeffs on;
}
but then I get a different error:
FOAM FATAL IO ERROR:
attempt to read beyond EOF
file: .../Axisymmetric2D/case/system/fvSchemes.divSchemes.default at line 29.
From function virtual Foam::Istream& Foam::ITstream::read(Foam::token&)
in file db/IOstreams/Tstreams/ITstream.C at line 82.
FOAM exiting
It seems like the tutorial is meant for an older version of OpenFOAM. I would appreciate if you could help me know what is the problem and how I can solve it.
The goal for me is to learn how to make axisymmetric mesh using Gmsh. so out of the box solutions or tutorials for the newer versions of OpenFOAM als would do.
P.S. I have reported the issue here in the Github repo
I was able to solve the issue by looking into the different versions of axisymmetricJet template provided in official OpenFOAM GitHub repo (version 2.3.x and version 5.x). Changes to be made:
in case/constant/RASProperties add these at the end:
kEpsilonCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
sigmaEps 1.3;
}
in case/constant/turbulenceProperties replace the line simulationType RASModel; with:
simulationType RAS;
RAS
{
RASModel kEpsilon;
turbulence on;
printCoeffs on;
}
in case/system/fvSchemes change the line div((nuEff*dev(T(grad(U))))) Gauss linear; to div((nuEff*dev2(T(grad(U))))) Gauss linear;
It the solver converges as expected. I still don't know what these changes mean and how they work. I will add them as soon as I figure that out. I have forked the GitHub repo here including the required edits.

how to add require_once to a wordpress template file

I am creating a wordpress template file.
I need to require_once() a file path. Where should I put the code?
<?php require_once("phpChart/conf.php");?>
It is giving me errors if I put it in my template file. It doesn't seem to work either in the header.php file.
If I include it in the template file I can a ton of errors. I think it needs to be in the header before the html.
Here are some of the errors:
Notice: Undefined offset: -1 in /xxx/wp-includes/post-template.php on line 262 Call Stack #TimeMemoryFunctionLocation 10.0003283432{main}( ).../index.php:0 20.0004287208require( '/xxx/wp-blog-header.php' ).../index.php:17 30.454546621040require_once( '/xxx/wp-includes/template-loader.php' ).../wp-blog-header.php:16 40.459646824600include( '/xxx/wp-content/themes/gazette-child/email.php' ).../template-loader.php:74 50.537247474312get_header( ).../email.php:18 60.537547477952locate_template( ).../general-template.php:45 70.537547478144load_template( ).../template.php:477 80.537747516408require_once( '/xxx/wp-content/themes/gazette-child/header.php' ).../template.php:501 90.581648215152the_excerpt( ).../header.php:56 100.581648215264get_the_excerpt( ).../post-template.php:336 110.581748215672apply_filters( ).../post-template.php:367 120.581748217056call_user_func_array:{/xxx/wp-includes/plugin.php:213} ( ).../plugin.php:213 130.581748217088wp_trim_excerpt( ).../plugin.php:213 140.581748217248get_the_content( ).../formatting.php:2609 " /> ( ! ) Notice: Undefined offset: -1 in /xxx/wp-includes/post-template.php on line 262 Call Stack #TimeMemoryFunctionLocation 10.0003283432{main}( ).../index.php:0 20.0004287208require( '/xxx/wp-blog-header.php' ).../index.php:17 30.454546621040require_once( '/xxx/wp-includes/template-loader.php' ).../wp-blog-header.php:16 40.459646824600include( '/xxx/wp-content/themes/gazette-child/email.php' ).../template-loader.php:74 50.537247474312get_header( ).../email.php:18 60.537547477952locate_template( ).../general-template.php:45 70.537547478144load_template( ).../template.php:477 80.537747516408require_once( '/xxx/wp-content/themes/gazette-child/header.php' ).../template.php:501 90.585448229760the_excerpt( ).../header.php:68 100.585448229840get_the_excerpt( ).../post-template.php:336 110.585448230048apply_filters( ).../post-template.php:367 120.585448231280call_user_func_array:{/xxx/wp-includes/plugin.php:213} ( ).../plugin.php:213 130.585448231312wp_trim_excerpt( ).../plugin.php:213 140.585448231392get_the_content( ).../formatting.php:2609 - http://xxx/email/">
Use require_once() or include() to include a file. You didn't post what error are you getting?
require('phpChart/conf.php'); in functions.php worked.

Compilation failed while installing plugin in wordpress

I could customize wordpress theme http://www.apptha.com/demo/video-stream in localhost well .
But I am tring to upload in server get the following error.
Warning: preg_replace_callback(): Compilation failed: missing opening brace after \o at offset 18 in /home/const/public_html/apptha/wp-content/plugins/contus-video-gallery/hdflvvideoshare.php on line 545
My site is http://constantin-entertainment.info/apptha/
here Wordpress video gallery plugin is used, the error pointed line is
$pageContent = preg_replace_callback( '/\[hdvideo ([^]]*)\o]/i', 'video_shortcodeplace', $pageContent );
Please help me..!
Looks like you need to escape the backslash,
$pageContent = preg_replace_callback( '/\[hdvideo ([^]]*)\\o]/i', 'video_shortcodeplace', $pageContent );
Open \wp-content\plugins\contus-video-gallery\hdflvvideoshare.php file and find add_filter('the_content', 'videogallery_pagereplace'); and replace with the following code.
add_shortcode('videohome','video_homereplace');
add_shortcode('videomore','video_morereplace');
add_shortcode('hdvideo','video_shortcodereplace');
Replace
$pageContent = preg_replace_callback('/\[hdvideo ([^]]*)\o]/i',
'video_shortcodeplace',
$pageContent
);
with
$pageContent = preg_replace_callback('/\[hdvideo\s*.*?=(\d+)\]/i',
'video_shortcodeplace',
$pageContent
);

How do i use the closurebuilder for compiling and minifying scripts

I am totally new to closure-library and am getting started. I just installed Python on my windows7 machine want to concatenate and minify the scripts. I ran through some commands as documented here but no gain. here are some parameters
Python installed in c:\python27\python.exe
Closure library in c:\closure\
Closure compiler in c:\closure\bin\build\compiler.jar
My Javascript file in D:\projects\closureapp\js\index.js
contents of the index.js is as below
/// <reference path="../closure/base.js" />
/// <reference path="../closure/dom/dom.js" />
/*Hello world into Closure Library Example*/
//Load the dom module
goog.require("goog.dom");
//refer the document body
var pageBody = document.body;
//after the body is loaded execute and add a header
pageBody.onload = function () {
//create a header for the page
var pageHeader = goog.dom.createDom('h1', { 'style': 'background-color:#EEE' }, 'Hello world!');
//append the header to the document body
goog.dom.appendChild(pageBody, pageHeader);
};
I executed the command below to produce compiled javascript but no gains
c:\python27\python.exe c:\closure\bin\build\c
losurebuilder.py --root=closure/ --root=d:\Projects\closureapp\js\ --
output_mode=compiled --compiler_jar=compiler.jar > d:\Projects\closureapp\js\output.js
i get some weird messages like below
c:\closure\bin\build\closurebuilder.py: Building dependency tree..
Traceback (most recent call last):
File "c:\closure\bin\build\closurebuilder.py", line 257, in <module> main()
File "c:\closure\bin\build\closurebuilder.py", line 204, in main tree = depstree.DepsTree(sources)
File "c:\closure\bin\build\depstree.py", line 56, in __init__ raise NamespaceNotFoundError(require, source)
depstree.NamespaceNotFoundError: Namespace "goog.async.Deferred" never provided.
Required in Source closure\messaging\portchannel.js
This looks like the same issue as http://code.google.com/p/closure-library/issues/detail?id=316

Resources