Problem Statement
So I do iTop Development ( A open source service desk software) .
While implementing a feature I got stuck on how to upload a file to the server directory but thanks to this stackoverflow question I was able to upload the file in my local machine with a project structure to test the feature. The minimal viable project went like this : -
./
├── index.html
├── index.js
├── upload.php
└── uploads
├── ocr.png
└── ocr_prev_ui.png
and I used the same code that was specified in that question.
But when I put that same code in an already existing extension itop-attachments to add a field that would upload a temp file which gets deleted after an ocr operation is run, It throws the following error:
I even Searched the same question on sourceforge (Error: Unknown class ''.)
But it seems that it does not apply to my case.
Replication
Try make a custom form that uploads file in the /var/www/html/tbitsm/env-production/itop-attachments directory, using this code :
$oPage->add('<fieldset>');
$oPage->add('<legend>OCR Attachment</legend>');
$oPage->add('<div id="AttachmentsContent">');
$oPage->add('<form id="ocr_form" action="'.utils::GetAbsoluteUrlAppRoot().'/env-production/itop-attachments/test.php" method="POST" enctype="multipart/form-data">');
$oPage->add('<label for="OCR">Upload Image to Scan for OCR (png,jpg,jpeg):</label>');
$oPage->add('<br>');
$oPage->add('<br>');
<-- This is where the Error is -->
$oPage->add('<input type="file" id="OCR" name="OCR" accept="image/png, image/jpeg">');
$oPage->add('<input type="submit" value="Upload OCR"/>');
<-- Outputs -->
<--Fatal error, iTop cannot continue. -->
<--Error: Unknown class ''.-->
$oPage->add('</form>');
$oPage->add('</fieldset>');
Now, Make an incident in iTop and attach a image in the newly created OCR Attachment formset
Now click upload.
You will see the same Issue as I do .
Footnote
Environment :
Ubuntu 20.04 ,
Apache 2.4,
PHP 7.4.3 ,
iTop 2.7
I am not able to solve this issue. Likely seems a PHP or iTop Speicific issue where it cannot find class="Incident" . I am not sure.
Related
I've got a php program, on my debian server.
If set it up and changed the php version to 8.1.
Now the server is giving me an error message:
Some non-versioned files are outdated - WARNING: One or more files that are not included in REDCap's version directory but reside in your web server's main REDCap directory were found outdated, and thus need to be replaced. Click the download button below to download a zip file that contains the files you need to replace.
I want to know what a non-versioned file is, so I can fix that problem.
After downloading that .zip file I took a look inside and I realized it was empty...
I didnt change anything in the Servers main directory...
Thank you
In REDCap server administration, application files can be either versioned or non-versioned. Versioned files are those files that exist within a directory named for the version, i.e. redcap_v13.1.0. Non-versioned files are those that are outside this versioned file structure, in REDCap's base directory.
Below is a sample directory structure (altered so this answer does not expose the file structure of a non-open application):
.
└──redcap
├── init.php
├── index.php
├── redcap_v13.1.0
│ ├── tests.ini
│ ├── unit.php
│ └── api.bat
├── tmp
│ └── index.php
└── debug.php
Files tests.ini, unit.php and api.bat are versioned, and everything else is non-versioned.
Upgrades to the REDCap application mostly affect versioned files, but occasionally an upgrade will modify non-versioned files, which the application itself is incapable of directly modifying on the server. In these cases the application directs the administrator to download a zip file containing the modified non-versioned files and instructions on installing them.
If this zip file was empty for you, then that might indicate an incomplete upgrade. Some admins in the community have recently advocated for publishing hashes alongside releases to allow admins to ensure that the release has been correctly downloaded.
If this issue persists (though your comment suggests not), then I'd recommend taking this issue to the REDCap Admin Community, which you ought to have access to if you can access the code.
I've got a single page that I want to demo for a non-profit I'm volunteering for, but the Heroku deployment just gives me the error from the title. The file directory is such:
--hotlabdemo
--assets
--javascript
home.js
--css
style.css
--images
a few images
composer.json
home.html
home.php
I have another page hosted there that is more or less the same thing, but a little different. The HTML/JS/CSS are different, but nothing that should prevent accessing the "/" on the server.
For reference, the php and composer for both pages are
{}
and
<?php include_once("home.html"); ?>
I opened a support ticket with Heroku, but was told
"Unfortunately, this appears to be an issue that falls outside the nature of
the Heroku Support policy. I recommend searching our Knowledge Base or
asking the community on Stack Overflow for more answers."
Any thoughts on why I might be prevented from accessing the page?
You can most likely fix this issue by creating a file "Procfile" in the root of your project. https://devcenter.heroku.com/articles/procfile
NOTE
Procfile naming and location
A Procfile is a file named Procfile. It should be named Procfile exactly, and not anything else. For example, Procfile.txt is not valid. The file should be a simple text file.
The file must be placed in the root directory of your application. It will not function if placed in a subdirectory.
The Procfile should define that you want to run PHP Server e.g.
web: vendor/bin/heroku-php-apache2 web/
https://devcenter.heroku.com/articles/getting-started-with-php#define-a-procfile
I hope you are well. I am brand new to coding and have spent a lot of time trying to find a solution to my question, without much luck.
I was trying to utilize Spotify's API with PHP but ran into thus far unsurmountable hurdles. Please see steps taken below:
1.) I downloaded the Spotify PHP Wrapper library here https://github.com/jwilsson/spotify-web-api-php, and saved it in the same directory as my app. I then created a composer.json file as below :
{
"require": {
"jwilsson/spotify-web-api-php": "^1.0.0"
}
}
2.) After creating and saving the composer.json file, I ran "composer install" in terminal in the same directory as where the composer.json file was stored, which led to the creation of a composer.lock file and a vendor folder.
3.) I then moved the composer.lock, composer.json and vendor folders to my online hosting service (ecowebhosting) via firebug, so that I can run and test the code. I also created a .php file that I moved to the server as well.
In my .php page, i declared the required files as such (below) and ran a sample query form the Spotify API PHP Wrapper documentation on github, to confirm whether or not I successfully loaded the library (the autoload.php folder was automatically created in the "Vendor" folder, after I performed step 2 above):
require 'vendor/autoload.php';
$tracks = $api->getAlbumTracks('1oR3KrPIp4CbagPa3PhtPp');
print_r ($tracks);
When I run the code above, I get the error below:
Notice: Undefined variable: api in /home/sites/amanka.com/public_html/content/SmallApps/ListeningPod/home.php on line 8 Fatal error: Call to a member function getAlbumTracks() on a non-object in /home/sites/amanka.com/public_html/content/SmallApps/ListeningPod/home.php on line 8
This error causes me to think that I have not installed the Library correctly. Please any ideas where I might be going wrong?
Thanks a lot
first thanks for your brilliant work on Restler, I am using it for some labs at the University and so far it works like a charm, really simple and elegant framework!
I've been using Restler 3.0 RC4 successfully until I updated to RC5 today. Now I'm having problems with the HtmlFormat. Whenever I try to access any of my web services that return HtmlFormat or try to enter the API Explorer, I'm getting a HTTP 500, "Unable to create cache directory /home/xxxxxxx/public_html/concrete/api/cache/php" . Also, I see a "Warning: mkdir() [function.mkdir]: No such file or directory in /home/xxxxxxx/public_html/concrete/Restler/vendor/Luracast/Restler/Format/HtmlFormat.php on line 367" .
Do you have any idea of what could be happening? In the upgrade, I just replaced my Restler framework folder with the RC5 one, without any changes in my API itself.
I would appreciate any help. Thank you!
Most of the template formats need a cache folder to keep their compiled files so that they run efficiently
Since RC5 we create a subfolder for the template type used. Even though php templates does not need compilation Restler attempts creating php folder under the default cache location, which is cache folder located in the same folder as the index.php
In your case it is
/home/xxxxxxx/public_html/concrete/api/cache
You should update the cache folder to keep it outside the web root by adding
Defaults::$cacheDirectory = '/home/xxxxxxx/cache';
And then make sure the cache folder is writable
Then HtmlFormat will create the php/twig/blade folder depending on your template preference and add the compiled files inside
The Yii2 preview was recently released and is available on github. I want to take it for a test drive, but the "documentation" so far gets outdated almost instantly since it is still under heavy development. I have tried to follow this guide on creating a simple CRUD app with Yii2, but it fails at the step:
php yiic.php app/create /var/www/yii2
With the error:
Could not open input file: yiic.php
Indicating that there is no file called yiic.php. The only folder within the framework folder is yii (framework/yii), and within that folder there is no file yiic.php, only Yii.php which when called in the command line gives the command list:
The following commands are available:
- asset
- cache
- help
- message
- migrate
Anyone managed to successfully setup a Yii2 app? Care to share how you got it done?
Seems like yiic has been removed for now, there are alternatives though, so read on.
It's all in the early stages, so the following method could break in the coming days/weeks/months. Therefore use with caution.
There are 2 ways to do this now:
Use composer. (I recommend this option.)
Directly copy the contents of yii2/apps/ directory to your apps directory, depending on the type of app you want to try.
There are currently 2 options for type of app - advanced, and basic. Both are in their respective directories within the yii2/apps/ directory, i.e yii2/apps/advanced and yii2/apps/basic.
For basic go through the basic readme.md, and for advanced go through the advanced readme.md.
The directions for using composer are given in the respective readme.md files. Including them here for completeness:
Basic app:
Install composer, if you don't have it.
Use composer to install the app alongwith dependencies(Yii):
php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-basic my_yii2_trial
Access app from http://localhost/my_yii2_trial/www
Advanced app:
Install composer, if you don't have it.
Use composer to install the app alongwith dependencies(Yii):
php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-advanced my_yii2_trial
According to readme, after step 2 app should be accessible, but composer was failing(see issue 439). With schmunk's tip, ran the install or install.bat command that gets copied by composer: ./install . Selected development environment (by entering choice 0 in the instructions that show up when running install command). Update: The command has been renamed to init, composer doesn't fail anymore, with fix from Qiang (check the issue 439 for more details).
Access app at: http://localhost/my_yii2_trial/frontend/www or http://localhost/my_yii2_trial/backstage/www
Here's how to copy the directory and get it working:
Basic app:
create your web-accessible directory for the app : my_yii2_trial
copy all files and folders from yii2/apps/basic/ directory to my_yii2_trial/ directory.
modify the my_yii2_trial/www/index.php file to point to the correct path for Yii.php.
For me it was within yii2/framework/yii/
comment the line that tries to include ../vendor/autoload.php file, I couldn't find that file anywhere, so its probably for some future use. it is the autoloader provided by composer.
Access from browser : http://localhost/my_yii2_trial/www
Advanced app:
create your web-accessible directory for the app : my_yii2_trial
copy all files and folders from yii2/apps/advanced/ directory to my_yii2_trial/ directory.
modify the my_yii2_trial/frontend/www/index.php file to point to the correct path for Yii.php. Similarly modify backstage/www/index.php.
comment the line that tries to include ../vendor/autoload.php file in both the index.php of backstage and frontend.
Access app at: http://localhost/my_yii2_trial/frontend/www or http://localhost/my_yii2_trial/backstage/www
Some important links to read more about this: issue 77, issue 108, issue 131, and wiki comment.
I am not sure how composer's autoloader is being used, so can't comment on that. Also in future versions, backstage might be renamed to backend.