Im trying to send my search variable to ontology and see if it does belong to any class or subclass as their property. how can i do that?
<?php
$search=$_GET['searchtext'];
if(empty($search)){
echo ("You don't enter anything.");
}
else{
echo ("String you enter is " . $search . " !");
}
require_once "owllib/OWLLib.php";
require_once "$OWLLIB_ROOT/reader/OWLReader.php";
require_once "$OWLLIB_ROOT/memory/OWLMemoryOntology.php";
$reader = new OWLReader();
$ontology = new OWLMemoryOntology();
$reader->read($filename, $ontology);
$class = $ontology->getClass($search);
echo("Ontology output is " .$class);
?>
Related
I have a this folder structure:
+ inc
++ functions.php
++ vendor
+ private
++ carddav
+++ check.php
my check.php looks like this and works:
<?php
require '../../inc/functions.php';
// CardDAV API
require '../../inc/vendor/autoload.php';
use MStilkerich\CardDavClient\{Account, AddressbookCollection, Config};
use Psr\Log\{AbstractLogger, NullLogger, LogLevel};
use Sabre\VObject\Component\VCard;
class StdoutLogger extends AbstractLogger {
public function log($level, $message, array $context = array()) {
if ($level !== LogLevel::DEBUG) {
$ctx = empty($context) ? "" : json_encode($context);
echo ">>> ".$message . $ctx . "<br />";
}
}
}
Config::init(new StdoutLogger());
$account = new Account(URL, USERNAME, PASSWORD);
$abook = new AddressbookCollection(URL, $account);
$vcard = new VCard();
?>
But now I would like to outsource this part into my functions.php:
functions.php
<?
// CardDAV API
require 'vendor/autoload.php';
use MStilkerich\CardDavClient\{Account, AddressbookCollection, Config};
use Psr\Log\{AbstractLogger, NullLogger, LogLevel};
use Sabre\VObject\Component\VCard;
class StdoutLogger extends AbstractLogger {
public function log($level, $message, array $context = array()) {
if ($level !== LogLevel::DEBUG) {
$ctx = empty($context) ? "" : json_encode($context);
echo ">>> ".$message . $ctx . "<br />";
}
}
}
Config::init(new StdoutLogger());
$account = new Account(URL, USERNAME, PASSWORD);
$abook = new AddressbookCollection(URL, $account);
?>
check.php
<?php
require '../../inc/functions.php';
$vcard = new VCard();
?>
But now I get this error when I open the check.php:
Fatal error: Uncaught Error: Class 'VCard' not found in check.php:26
Where is my mistake?
Tank you !
Imports using use statement work on a per file basis. I.e. classes need to be imported in the file where they're used. In your case remove Sabre\VObject\Component\VCard import from functions.php and move it to check.php where VCard class is actually used.
I'm trying to login to the following URL: pitangui.amazon.com
I have tried using cURL as well as libraries like https://barebonescms.com/documentation/ultimate_web_scraper_toolkit/
However, I'm getting the following error using the webscraper via Amazon:
This is my PHP code:
<?php
require_once "support/http.php";
require_once "support/web_browser.php";
require_once "support/simple_html_dom.php";
$url = "https://pitangui.amazon.com";
$web = new WebBrowser(array("extractforms" => true));
$result = $web->Process($url);
if (!$result["success"]) echo "Error retrieving URL. " . $result["error"] . "\n";
else if ($result["response"]["code"] != 200) echo "Error retrieving URL. Server returned: " . $result["response"]["code"] . " " . $result["response"]["meaning"] . "\n";
else
{
$form = $result["forms"][0];
$form->SetFormValue("email", "myemail#gmail.com");
$form->SetFormValue("password", "mypass");
$result2 = $form->GenerateFormRequest("signIn");
$result = $web->Process($result2["url"], "auto", $result2["options"]);
if (!$result["success"]) echo "Error retrieving URL. " . $result["error"] . "\n";
else if ($result["response"]["code"] != 200) echo "Error retrieving URL. Server returned: " . $result["response"]["code"] . " " . $result["response"]["meaning"] . "\n";
else
{
// Do something with the results page here...
print_r($result);
}
}
?>
I'm first trying to get the login working, then I will grab the cookie via $_SERVER['Cookie']
add
$form->SetFormValue("create","0");
I am trying to have this script check if an application exists, and if it does, determine whether it is in the "Accepted" or "Denied" section. The two allowed positions are "Mod" and "Admin".
I have the following code on index.php:
HTML
<!DOCTYPE HTML>
<html>
<body>
<form action="statuscheck.php" method="GET">
<h1>Is this a mod or admin application?</h1>
<input type="radio" name="MOA" value="MOD">Mod</input><br>
<input type="radio" name="MOA" value="ADMIN">Admin</input>
<h1>Put Application ID Below</h1>
<input type="text" name="APPID" placeholder="XXXX-XXXX-XXXX-XXXX" /><br><br>
<input type="submit" value="Check Status" />
</form>
</body>
</html>
This takes the information from the user (to tell statuscheck.php where to go ).
Here is statuscheck.php
PHP
<?php
$APPID = $_GET['APPID'];
$MOA = $_GET['MOA'];
$ROOT = $_SERVER['DOCUMENT_ROOT'];
function modCheck() {
$ACCEPTEDFILEPATH1 = $ROOT . 'public_html/apply/mod- applications/accepted/' . $APPID . '.php';
$DENIEDFILEPATH1 = $ROOT . 'public_html/apply/mod-applications/denied/' . $APPID . '.php';
if (FILE_EXISTS($ACCEPTEDFILEPATH1)) {
echo 'Your moderator application was accepted';
} elseif (FILE_EXISTS($DENIEDFILEPATH1)) {
echo 'Your moderator application was denied';
} else {
echo 'Error : Your application ID is incorrect';
}
}
function adminCheck() {
$ACCEPTEDFILEPATH2 = $ROOT . 'public_html/admin-applications/accepted/' . $APPID . '.php';
$DENIEDFILEPATH2 = $ROOT . 'public_html/admin-applications/accepted/' . $APPID . '.php';
if (FILE_EXISTS($ACCEPTEDFILEPATH2)) {
echo 'Your admin application was accepted';
} elseif (FILE_EXISTS($DENIEDFILEPATH2)) {
echo 'Your admin application was denied';
} else {
echo 'Error : Your application ID is incorrect';
}
}
if ($MOA == "MOD") {
modCheck();
} elseif ($MOA == "ADMIN") {
adminCheck();
} else {
echo 'Please go back and choose mod or admin';
}
I have my PHP tags but they won't work on here so I left them out.
Every time I put a valid ID and select "Mod", the code echos
Error : Your application ID is incorrect.
I do not see anything wrong with my code, and don't understand how it fails the if statements. Can anyone help me ?
EDIT
I have set my php variables at the top of statuscheck.php, they just won't show up in the code on StackOverflow.
They are:
PHP
$APPID = $_GET['APPID'];
$MOA = $_GET['MOA'];
$ROOT = $_SERVER['DOCUMENT_ROOT'];
I have made a site where user login with google,where a popup window opens for login,when user click the submit button,the popup window close & user redirect to another page.
I have done the code but it works fine in FF bt not working in chrome
This is my code,can anyone plz suggest what changes I need to do so that it works in chrome also.
<?php
#session_start();
require 'openid.php';
try {
$openid = new LightOpenID;
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://www.google.com/accounts/o8/id';
$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email');
// #header('Location: ' . $openid->authUrl());
echo "<script>location.href='".$openid->authUrl()."'</script>";
}
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
if($openid->validate())
{
'User <b>' . $openid->identity . '</b> has logged in.<br>';
"<h3>User information</h3>";
$_SESSION['identity'] = $openid->identity;
$identity = $openid->identity;
$attributes = $openid->getAttributes();
$_SESSION['email'] = $attributes['contact/email'];
$_SESSION['first_name'] = $attributes['namePerson/first'];
$_SESSION['last_name'] = $attributes['namePerson/last'];
/* "mode: " . $openid->mode . "<br>";
"identity: " . $identity . "<br>";
"email: " . $email . "<br>";
"first_name: " . $first_name . "<br>";
"last_name: " . $last_name . "<br>";*/
}
else
{
echo 'User ' . $openid->identity . 'has not logged in.';
}
echo "<script>window.close();</script>";
echo '<script>window.opener.location.href="index2.php"</script>';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
?>
i believe window.close() is not working in chrome for you.
Once i faced the problem i fixed the problem using
replace window.close(); with the code below
window.open('', '_self', ''); //simple bug fix
window.close();
Also try putting the this
echo '<script>window.opener.location.href="index2.php"</script>';
echo "<script>window.open('', '_self', '');window.close();</script>";
Hope it works for you too.
if not please be more specific about the question
Please try with below any one of the option
echo('opener.window.location.reload(true); window.close();');
or
echo('window.opener.location.reload(false); window.close();');
if still problem exist let me know
I am using php imap functions to parse the message from webmail. I can fetch messages one by one and save them in DB. After saving, I want to delete the inbox message. imap_delete function is not working here. My code is like that:
$connection = pop3_login($host,$port,$user,$pass,$folder="INBOX",$ssl=false);//connect
$stat = pop3_list($connection);//list messages
foreach($stat as $line) {
//save in db codes...
imap_delete($connection, $line['msgno']);//flag as delete
}
imap_close($connection, CL_EXPUNGE);
I also tested - imap_expunge($connection);
But it is not working. The messages are not deleted. Please help me out...
You are mixing POP and IMAP.
That is not going to work. You need to open the connection with IMAP. See this example:
<?php
$mbox = imap_open("{imap.example.org}INBOX", "username", "password")
or die("Can't connect: " . imap_last_error());
$check = imap_mailboxmsginfo($mbox);
echo "Messages before delete: " . $check->Nmsgs . "<br />\n";
imap_delete($mbox, 1);
$check = imap_mailboxmsginfo($mbox);
echo "Messages after delete: " . $check->Nmsgs . "<br />\n";
imap_expunge($mbox);
$check = imap_mailboxmsginfo($mbox);
echo "Messages after expunge: " . $check->Nmsgs . "<br />\n";
imap_close($mbox);
?>
Actually the functions names are like pop3. but they perform imap functionality. like -
function pop3_login($host,$port,$user,$pass,$folder="INBOX",$ssl=false)
{
$ssl=($ssl==false)?"/novalidate-cert":"";
return (imap_open("{"."$host:$port/pop3$ssl"."}$folder",$user,$pass));
}
function pop3_list($connection,$message="")
{
if ($message)
{
$range=$message;
} else {
$MC = imap_check($connection);
$range = "1:".$MC->Nmsgs;
}
$response = imap_fetch_overview($connection,$range);
foreach ($response as $msg) $result[$msg->msgno]=(array)$msg;
return $result;
}