Installing Zend Gdata Client library - php

Hi this is my first post on here. I am trying to install the Gdata Zend Client library without much success.
I have used these resources + scoured Stack Overflow.
https://developers.google.com/gdata/articles/php_client_lib
http://jeromejaglale.com/doc/php/google_calendar_api
I want to be able to add,edit etc events on google calendar via PHP. My problem/question is i really dont understand what the include_path settings are all about and how to set them in order to make the class work. Of course i checked php manual regarding this but still draw a blank.
I have downloaded the relevant class and uploaded it to my web root. In the past i would just include a class by using php include at the top of the page and this would suffice.
I am of the understanding that i need to change the php.ini file to show php where my class is. Does this mean that i have to put my class somewhere else other than the web root.
I am terribly confused about this step and i know that if i can get it installed, actually using the class should be relatively easy.
Thanks for any help.

Welcome! Your Q is about include files rather than ZF elements.
Understanding where the include setting can be made (and subsequently overridden) is an absolute key bit of information.
You need to find out where it is on the server you are working on.
echo ini_get('include_path');
Then dash off and really, really read the corresponding manual page.
Try out including a very simple file with an echo statement, and you will regain your sanity and confidence.
http://www.php.net/manual/en/function.include.php
Get that working then have a play with this:
http://www.php.net/manual/en/function.ini-set.php
The experience how you can include a file from the same directory (not generally a good idea if that is a public webpage - inside your webroot)
Then if you want to really chase this thing down, look at where you can set this in Apache and per-directory in .htaccess files.
Finally, you can just include a file by telling include/require the exact path from the top of the tree;
include /var/www/includes/libraries/and/so/on.php;
There are SO many places you can set and override this that you are really best off finding out where the server thinks the include directory is and putting your compoenents in there:
Now, when that comes to ZF stuff, I (on Deb and Ubuntu anyhow) put the contents of
Zend Framworks version XYZ ZendFramework/lib/Zend <-that folder into:
/usr/share/php/Zend <-into this place
Then setup your autoloader and Robert is your mothers brother...

Zend/Gdata.php line 124 is like this:
public static function import($uri, $client = null,$className=’Zend_Gdata_Feed’)
Change that to this:
public static function import($uri, $client = null,$className=’Zend_Gdata_Feed’, $useObjectMapping = true)

Related

PhpStorm won't resolve includes using constants

This used to work, but it stopped working recently. I don't think anything changed in my settings, but I have poured over them for a couple hours now just to make sure. I have checked all over google and SO too. Please pay attention to the details before claiming "this was answered over here..." Thanks. :)
Assumptions and Requirements
Assume we have two files:
<project_root>/index.php
<project_root>/folder/file.php
Assume our project root is /home/me/project.
We want to include file.php from index.php. We expect PhpStorm to be able to resolve the file path and allow us to do nifty IDE things like "Go To Declaration."
What works
require 'folder/file.php';
require '/home/me/project/folder/file.php';
$root = '/home/me/project/';
require $root.'folder/file.php';
What No Longer Works
define('ROOT_DIR', "/home/me/project/");
require ROOT_DIR.'folder/file.php';
PhpStorm does recognize the value of ROOT_DIR when I mouseover, but it highlights home and says something like: Path '"/home/me...folder/file.php' not found
Why Use a Constant Anyway?
To keep this simple, I've left out details that are not necessary to illustrate the problem. The primary thing I'd like to address is why this used to work but no longer does, and/or how can I make it work again.
Sorry, can't help. What are you really trying to do?
Here are the details I left out. If we can't solve the primary issue, perhaps we can find a good work around.
I'm working with an existing codebase. Most files require a config.php file that defines root_dir() for getting the web/project root. PhpStorm wasn't resolving those paths (understandably so), so I created a constant to takes it's place. That makes more sense anyway.
In today's battle, I discovered that you can do this:
/** #define "root_dir()" "/home/me/project/" */
// or
/** #define "ROOT_DIR" "/home/me/project/" */
If you put that anywhere in the file then PhpStorm is able to resolve all the includes/requires in that file. BUT, it only works in that file, even if you try to include/require it in another file. You'd have to do this to EVERY file to get it working everywhere. Nope. Nuh-uh. No thank you. I need to reference the absolute path to the project/web root in a way that PhpStorm will recognize across the whole project.
#LazyOne answered this in the comments. This is a bug in the latest release, and it's being tracked here: https://youtrack.jetbrains.com/issue/WI-31754
Until this gets patched I've created this work around:
Using Keyboard Maestro, I created a hotkey that will paste the #define comment at the top of the file and return the cursor to its original position. Download the macro here. Import that and edit the text.
Edit: You may actually need to edit the file in a regular text editor. One of the file paths may need to be changed to work on your system.
Note: I'm using a modified version of the Mac Eclipse keyboard layout in PHPStorm. I'm not sure that will matter.
Also, be aware that many of your "changed files" will simply have this mapping at the top of the file, and this mapping may not be correct for you teammates. I'm simply excluding those changes from my commits.

How to move Joomla's configuration.php file above the root folder in a web host?

I have installed a security solution in my Joomla website,and it's suggest that to put the configuration.php file above the Public_html Folder,how could it be possible?
how to tell the CMS to recognize the new location?
is the solution would be valid in all versions of the Joomla CMS? ,if it's not,so please
write:
1st:Joomla 2.5 Solution.
2nd:Joomla 3 Solution.
you would need to modify the defines.php file located in the includes folder.
Specifically this line:
define('JPATH_CONFIGURATION', JPATH_ROOT);
And change JPATH_ROOT to the correct path.
But the problem with this is that you are modifying a core file so if an update changes the defines.php file it will overwrite your changes and will break your setup. You will need to reedit the file.
Also the JPATH_CONFIGURATION constant may be used for other things within the CMS that are not specifically trying to get the configuration.php file so make sure to check that it will not adversely affect other parts of the cms before doing this in production.
Alternatively you can change the frameworks.php file (also in the includes folder) directly to change from where the configuration is loaded from
ob_start();
require_once JPATH_CONFIGURATION . '/configuration.php';
ob_end_clean();
Just change the require_once line to the correct path.
Again since this is a core file it could be changed by an update. But this may also affect other parts if the config file is loaded manually in components or other parts of the cms.
Simply answer is don't do it. This would mean you would have to do what #Patrick has suggest which is correct and will work, however it means editing a core Joomla file. This is not a good idea as in your case, if you ever update Joomla, you will have to perform this change every time and it you forget (which is likely), your site will stop working completely.
I would strongly suggest you find a different "security solution" which does not involve having to modify any core Joomla files.
If you could define what you mean by "security solution", then maybe an alternative could be provided for you
I didn't dig for 'since when this has been implemented', But it can be done without changing the core.
Joomla looks for a defines.php in the root and if its present, imports it. And then if it finds a constant named _JDEFINES defined, it doesn't load the original file, effectively overriding it completely.
So, If you wish to override the defines its pretty easy and all you have to do is copy the contents of the defines.php file from under the webroot/includes/ path and paste it inside the one we created in the webroot. And you can change the following constant as per your taste.
define('JPATH_CONFIGURATION', JPATH_ROOT."/my/supersecret/directory");
Now there is one more thing left to be done and then we are good to go :)
You have to prepend the following lines to the top of our override file (the defines.php in the webroot).
define('JPATH_BASE', __DIR__);
define('_JDEFINES', 1);
This constant conveys to the framework that the defines have been overridden and to use the new file accordingly (Last time I checked, this flag/constant is checked at around 10 different places all over the framework eg. here, so its important)
Also I have seen this feature available with Joomla v2.5.0 and v3.8.8 as per your requirements in the question.
Edit: Remember you have to repeat the same procedure for administrator folder too if you want admin panel to work, and remember that administrator has its own /includes/defines.php

How to include php file in drupal 7

I'm coding a form in Drupal 7, and I want to 'include' a php file that adds my DB connection variables to my code.
I've tested my code in several ways, and I'm sure that the 'include' makes me get a WSOD when I run Cron in my site.
I've Googled about this and I tried:
include("/sites/all/libraries/php/connection.inc");
include("./sites/all/libraries/php/connection.inc");
include"./sites/all/libraries/php/connection.inc";
I also tried the above with '.php' extension.
And my last try:
define('__ROOT__', dirname(dirname(__FILE__)));
include(__ROOT__.'/sites/all/libraries/php/connection.inc');
Sometimes I get a WSOD when trying to run Cron, and sometimes my page styles get broken when I submit a form.
What is the correct way to include a PHP file manually in Drupal? Note that I don't want to use the 'Drupal way' to do this or to use the webform module. I want to code it manually with PHP.
The libraries directory should only be used to store files shipped as a library through the libraries module (see here https://drupal.org/project/libraries).
For both examples lets assume library.inc is our file and relative_path_to is the relative path based on the module directory to our library.inc file.
To just include a file you can use:
require(drupal_get_path('module', 'module_name') . '/relative_path_to/library.inc');
And to do it the Drupal way (https://api.drupal.org/api/drupal/includes!module.inc/function/module_load_include/7):
module_load_include('inc', 'module_name', '/relative_path_to/library');
Cheers,
j
Try this ways
1) require 'includes/iso.inc';
2) include_once 'includes/iso.inc';
3) include ('includes/iso.inc');
OR Drupal Ways
include_once DRUPAL_ROOT . '/includes/iso.inc';
In my opinion these are correct Drupal (7) ways to include code:
module_load_include(); function - Drupal API documentation - to include any PHP files from within your or other modules where needed,
files[] = ... in your_module.info file to autoload include classes and interfaces within your own module - Writing .info file documentation.
Libraries module provides it's own way to include external PHP files from the libraries.
The second answer is the correct "Drupal way". The one that was accepted as the answer has many potential pitfalls if locations of things change. Using drupal_get_path is the best way. This is also especially true if you are trying to include a file that may not be fully bootstrapped during a module update hook.

Modifying .htaccess file to set include path to ZendFramework

I'm trying to include ZendFramework on a web site with no luck. Lately I gave a try at modifying the .htaccess file like this:
php_value include_path ":/home/u230474/Zend"
I also tried
php_value include_path ".:/home/u230474/Zend"
But on each case what happened was that I no longer could view any of the pages in the web site.
I did these modifications since I'm trying to make the system understand the following code:
<?php
$libreria='/Zend/ZendFramework/library';
set_include_path(get_include_path().PATH_SEPARATOR.$libreria);
require_once('Zend/Loader/Autoloader.php');
Zend_Loader_Autoloader::getInstance();
I've been trying things many days long now, and although I've talked to my provided we seem to have problems understanding the requirements.
I did a test to check the installation of ZendFramework with a script called InstallationChecker.php which is supposed to indicate the success in installing Zend Framework, and actually the script throws an error like this:
Exception thrown trying to access Zend/Loader.php using 'use_include_path' = true. Make sure you include Zend Framework in your include_path which currently contains: .:/usr/lib/php:/usr/local/lib/php
Which is why I tried modifying .htaccess
Does anyone know if I'm doing things wrong (obviously yes)? What is the right way to modify the htaccess file so that `/usr/lib/php and /usr/local/lib/php are included as well?
Also I've read that when you include a htaccess you must include also a .htaccess file to every subdirectory that makes an include. Most of my php scripts are directly in the public folder, but still I have many of them on subdirectories as well. How am I supposed to proceed?
I made some changes following Mike's advise and included the whole custom path like this:
$libreria='Zend/ZendFramework/library/Zend/Loader';
then I looked at php.info and it still doesn't show any changes to include_path. Additionally, I noticed that the error in the test I'm running to check if ZendFramework is installed is telling me there's a class Loader.php in the Zend folder, which is actually there, but still nothing gets loaded.
Ok so I did a couple of test to see what's going wrong, since the Zend Framework seems to load ok. First I added this code to the file 'libreria.php' which sets the include path (apparently alright, since the library is loaded). I did this:
$libreria='/home/u230474/public_classes/Zend/ZendFramework/library';
set_include_path(get_include_path().PATH_SEPARATOR.$libreria);
require_once('Zend/Loader/Autoloader.php');
$libload = Zend_Loader_Autoloader::getInstance();
if(!$libload) echo "Librería Zend Framework cargada"; else echo "Error al cargar la librería";
And as a result, it outputs: "Error al cargar la librería".
I also set up a tiny test to see if there's something wrong with the case sensitivity. On some of the pages that are having trouble, I put this code inmediately after including the header and the library:
//codigo para probar equidad de nombre de archivo---------->
$filename = basename($_SERVER['SCRIPT_FILENAME']);
$request = basename($_SERVER['SCRIPT_NAME']);
if($filename != $request)
die('Case of filename and request do not match!');
And it does not die, so it's ok. (If I get it right the result would be different if there was a slight difference in my file names, as are seen on the browser address, and as are seen by the server, but maybe I'm wrong).
Then, there's something going on with the way I call the Autoloader.php class, but I don't see a different way of calling it than the static method on Zend's introduction to Autoloader documentation, where it says 'Autoloader, basic usage'
.htaccess is probably not the place to make this change, as it will be more difficult to append the new path you want to include to the existing. What you did was overwrite all the include paths with just the one you specified in .htaccess. This blowd things up.
If you look at the 2nd line of the PHP code you included, it shows you how to append to the include path (by getting the current path and appending a new path to it.) Just do similar for the path you want to include.

Including a php file in Joomla! 1.5 that calls another php file

I would like to include a PHP program into a Joomla! article, this program calls different PHP files that are used to display what I want, I have tried to install different Plugins such as Jumi, directPHP and others, but I keep getting the following error:
Application raised an exception class EDatabaseError with message 'Cannot connect to database server:mysql error: [0: Connection error to server '' with user ''] in CONNECT(, '', '**', )
'
The program runs fine Standalone, however it does not work when I'm running it on Joomla.
The connection parameters are obtained from an include "config.php" but it seems that they won't get the includes from the included PHP file.
Also when I try to include a menu I have made, which works standalone, redirects me to the index.php of Joomla! root dir.
Thanks.
I've done things similar to this, but have had to install a couple of extensions to get them to work.
First, i use the jce WYSIWYG.
then installed place anywhere (which lets you place modules inside articles)
create a new module, type=Custom HTML
code your php there...
I know this isn't exactly what you're describing, but it's the closest i've come in my experience.
If it doesn't work right away, be sure to check for the settings withing the JCE WYSIWYG so it's not breaking your php.
hope this helps!
Try to use 'Flexi Custom Code' extension is a good one
check it: http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/15251
Its a module extension which you can use with 'module anywhere' to place in the 'content area'(article). For calling different php file you can use the php include or required once code
Please feel free to ask if any doubts are there....implementing this

Categories