How could I add a logout link in the else portion of code, after the "echo $upme->display();" ...
<?php
global $upme;
if (!is_user_logged_in()) {
echo $upme->show_registration();
echo $upme->login();
}
else { echo $upme->display();
}
?>
I tried a few things including the below code but I keep getting internal error ...
<?php
global $upme;
$html1 = 'Logout';
if (!is_user_logged_in()) {
echo $upme->show_registration();
echo $upme->login();
}
else { echo $upme->display();
echo $html1;
}
?>
Thank You
There's a small syntax error:
$html1 = 'Logout';
500 is generally an "I can't find that" error. What page is this from? get_permalink may be returning false. Try outputting that function to see what you get back.
<?php echo get_permalink(); ?>
Related
I am using google-drive-sdk to upload a pdf file (dynamically generated in the php web app) to Gdrive.
About my app
On click of submit button the users see a THANKYOU displayed on the page. At the background
pdf file gets generated
and this file needs to be uploaded to Gdrive account --(configured the client id & secret key for the app in Google Console)
:
I am able to upload to the configured GDrive but first time to authenticate I run the url(redirect url given in Google Console) in browser(*say
http://localhost:3422/wordpress/wp-content/plugins/mktProc/google-api-php-client/gDrive_access/pdf_results_upload.php
*)
This takes me to GDrve page and prompts Allow\Deny Access.
I click Allow and then am able to upload to Grdive.
But I would like this to happen without prompts for Allow\Deny for the user to interact.
Please give me details on what I need to add so that when user clicks the Submit button , automatically the generated file gets inserted to GDrive.
I read lot in net but couldn't understand and get it to work.
Please help me with steps and code to include.
The code I am using
<?php
include_once "templates/base.php";
if(!session_id()){session_start();}
require_once realpath(dirname(__FILE__) . '/../autoload.php');
$pdf_filename='';
try
{
if(isset($_SESSION['pdf_filename']) && $_SESSION['pdf_filename'])
$pdf_filename=$_SESSION['pdf_filename'];
}
catch(Exception $ex)
{
echo ("This is for GDrive Upload from CalWeb");
}
$pfdStoragePath=dirname(__FILE__)."/../../vendor/pdf/".$pdf_filename;
/************************************************
ATTENTION: Fill in these values! Make sure
the redirect URI is to this page, e.g:
http://localhost:8080/fileupload.php
************************************************/
$client_id = 'xxxx.apps.googleusercontent.com';
$client_secret = 'xxxxSB0tNVy';
$redirect_uri = 'http://localhost:3422/wordpress/wp-content/plugins/mktProc/google-api-php-client/gDrive_access/roi_results_upload.php';
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->addScope("https://www.googleapis.com/auth/drive");
$client->setAccessType("offline");
$client->setApprovalPrompt('force');
$service = new Google_Service_Drive($client);
if (isset($_REQUEST['logout'])) {
unset($_SESSION['upload_token']);
}
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['upload_token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['upload_token']) && $_SESSION['upload_token']) {
$client->setAccessToken($_SESSION['upload_token']);
if ($client->isAccessTokenExpired()) {
unset($_SESSION['upload_token']);
}
} else {
$authUrl = $client->createAuthUrl();
}
/************************************************
If we're signed in then lets try to upload our
file.
************************************************/
try {
if ($client->getAccessToken()) {
if($pdf_filename!=="")
{
$file = new Google_Service_Drive_DriveFile();
$file->setTitle($pdf_filename);
$file->setDescription('Document');
$file->setMimeType('application/pdf');
$result = $service->files->insert(
$file,
array(
'data' => file_get_contents($pfdStoragePath),
'mimeType' => 'application/pdf',
'uploadType' => 'multipart'
)
);
//echo $result->webContentLink;
$pdf_filename="";
unset($_SESSION['pdf_filename']);
}
//if (isset($result) && $result) $_SESSION['webContentLink']=$result->webContentLink;
//echo $result->webContentLink;
}//if ($client->getAccessToken()) {
} catch (Exception $ex) {
echo '';
}
?>
<div class="box">
<div class="request">
<?php if (isset($authUrl)): ?>
<a class='login' href='<?php echo $authUrl; ?>'>Connect Me!</a>
<?php else: ?> <?php echo "Access Allowed" ?>
<?php endif; ?>
</div>
<?php if (isset($result) && $result): ?>
<div class="shortened">
<?php echo "aaa"; ?>
<?php echo $result->webContentLink; ?>
<?php echo "bbb"; ?>
</div>
<?php endif ?>
<?php if($pdf_filename==="") ?>
<?php echo "This is for GDrive Upload from MiniROI" ?>
</div>
I want to pass $ids variable retrieved from db from page1 to page2 with session method but the code doesn't work or overwrites the variable.
page1
<?php
$queryString = "WHERE id='$id'";
$sqls = mysql_query("SELECT ids FROM markers $queryString");
$i=0;
while($row=mysql_fetch_array($sqls)) {
$_SESSION['ids'][$i]=$row['ids'];
echo $_SESSION['ids'][$i];
echo 'Modify<br />';
$i++;
}
//echo $_SESSION['ids'];
?>
page2
<?php
session_start();
include_once "scripts/connect_to_mysql.php";
$ids= $_SESSION['ids'].[$i];
//echo $ids;
?>
Thanks a lot for help.
you must do also session_start(); in page1 to work with sesion variables.
your code should work like that:
while($row=mysql_fetch_array($sqls)) {
$arrays[]=$row['ids'];
$_SESSION['ids']= $arrays[];
echo $_SESSION['ids'][0];
echo $_SESSION['ids'][1];
.......
echo 'Modify<br />';
}
page2
<?php
session_start();
include_once "scripts/connect_to_mysql.php";
$ids= $_SESSION['ids'];
echo $ids[0];
echo $ids[1];......
?>
I'm trying to build a form in Codeigniter so that its elements are part of a table and are therefore aligned nicely. Here's the view page:
<div id="login">
<h3>Log in</h3>
<?php
$attributes = array('id'=>'form_login');
echo validation_errors();
echo form_open('login/main', $attributes);
//probably a bad idea to load libraries in views, but what the heck?!
$this->load->library('table');
$this->table->add_row('Username', form_input('username'));
echo $this->table->generate();
//echo 'Username: ';
//echo form_input('username') . '</br>';
echo 'Password: ';
echo form_password('password') . '</br>';
echo form_submit('submit', 'Log in');
?>
<br/><br/>
Forgot Password <br/>
New User? Register
</div>
The two lines commented out is how it was earlier. Now I'm getting the following error: Call to a member function add_row() on a non-object. Why is table a non-object? I've tried loading the library in the controller but the error persists. Please help!
In codeigniter, the global codeigniter object is not available in your views, so you have to get a reference to it.
Try the following
$ci =& get_instance();
Put that at the top, and replace your calls to $this like so:
$ci->load->library('table');
$ci->table->add_row('Username', form_input('username'));
echo $ci->table->generate();
I'm wondering if anyone could provide me with some advice on where I went wrong. I'm trying to get a photo to resize when loaded in a DIV but the photo keeps taking it's own dimensions. Does anyone have any idea why my code isn't working? Thank you in advance!
if($row['coverphoto'] === NULL){
echo"<li>";
echo"<img src='images/slider-4.jpg'>";
echo "<div class='banner'>Customize Your Banner!</div>";
echo "</li>";
}
else{
echo "<li>";
echo "<img style='height:auto; width:auto; max-width:1025px; max-height:503px;' src='/coverphotos/" . $row['coverphoto'] . "'/><br />";
echo "<div class='banner'>Customize Your Banner!</div>";
echo "</li>";
}
?>
Try this,
else{
echo "<li>";
echo "<div style="width:50px;height:50px;"><img style='height:50px; width:50px;' src='/coverphotos/" . $row['coverphoto'] . "'/></div><br />";
echo "<div class='banner'>Customize Your Banner!</div>";
echo "</li>";
}
If it is not worked means, please check your, css file
<li>
styles. May that style makes this mistake.
I have this theme and when I want to add the "Read more" option using the "Insert More Tag", the theme adds a read more icon below. What I want to do: remove the "read more" icon and show the "read more" at the end of the text (not below the text -- this is important). Please check the visual instruction below.
Thanks in advance for the help. I'm really grateful.
(p.s. I know very little how to edit html files, if not at all)
Visual instruction --> http://bit.ly/V8fU8k
Theme --> http://bit.ly/13I3x7U
you can change the Read More option in loop.php file in your theme folder
Remove this code
<?php if (option::get('display_readmore') == 'on') { ?><span class="readmore"><?php _e('Read more', 'wpzoom'); ?></span><?php } ?>
find
<?php if (option::get('display_content') == 'Full Content') { the_content(''); } else { the_excerpt(); } ?>
and add code after this
<?php _e('Read more', 'wpzoom'); ?>
Please replace in loop.php file in your theme
<?php if (option::get('display_content') == 'Full Content') { echo get_the_content(''); } else { echo get_the_excerpt(); } ?>
to
<?php if (option::get('display_content') == 'Full Content') { echo get_the_content(''); } else { echo get_the_excerpt(); } ?>
<?php _e('Read more'); ?>
This will help you to put read more near end of the post.