// get root constants
if (!defined('WW_ROOT')) {
    include_once '../../ww_config/model_functions.php';
}
$url = $_SERVER["PHP_SELF"] . '?sess=' . $_GET['sess'] . '&author_id=' . $_GET['author_id'];
// now bring in our functions
//include_once(WW_ROOT.'/ww_config/model_functions.php');
//include_once(WW_ROOT.'/ww_config/controller_functions.php');
include_once WW_ROOT . '/ww_config/author_controller_functions.php';
include_once WW_ROOT . '/ww_config/author_view_functions.php';
include_once WW_ROOT . '/ww_config/combined_functions.php';
// pagination parameters
$page = empty($_GET['page']) ? '1' : (int) $_GET['page'];
// upload image
if (isset($_POST['upload_image']) && $_POST['upload_image'] == 'upload') {
    $upload_success = insert_image();
}
// get images
$all_images = get_images(7);
// $author_images = list_images(7,1);
$total_pages = !empty($all_images) ? $all_images[0]['total_pages'] : 0;
$total_images = !empty($all_images) ? $all_images[0]['total_images'] : 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
	<script type="text/javascript" src="<?php 
echo WW_WEB_ROOT;
?>
/ww_edit/_js/jquery.js"></script>
	<script type="text/javascript">
// Check file size
if ($_FILES["fileToUpload"]["size"] > 5000000 && $uploadOk == 1) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if ($uploadOk == 1 && (strtolower($imageFileType) != "jpg" && strtolower($imageFileType) != "png" && strtolower($imageFileType) != "jpeg" && strtolower($imageFileType) != "gif")) {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    echo $imageFileType;
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo " Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file " . $img_name . " has been uploaded. <br/>";
        $new_img_name = explode(".", $img_name);
        $count_var = count($new_img_name) - 1;
        $file_ext = $new_img_name[$count_var];
        $user_img_name = $new_file_name . "." . $file_ext;
        $new_user_img_name = $target_dir . $user_img_name;
        $message = $user_img_name . "is uploaded";
        insert_image($user_img_name, $new_file_name);
        rename($target_file, $new_user_img_name);
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
header('location: profiles.php');
                 echo $result['ERRCODE'];
             }
         }
     } else {
         /* Commit to database */
         OCICommit($db_conn);
         OCILogoff($db_conn);
         /* Redirect to login page */
         header('Location: user_profile.php');
         exit;
     }
 } else {
     if (array_key_exists('editUserImage', $_POST)) {
         $imageindex = $_POST['imgindex'] + 1;
         $imageurl = $_POST['img'];
         $result = insert_image($user_userid, $imageurl, $imageindex);
         if ($result["SUCCESS"] == 0) {
             if ($result["ERRCODE"] == 2290) {
                 $picErrmsg = "Your image is invalid.";
             } else {
                 if ($result["ERRCODE"] == 1400) {
                     $picErrmsg = "Your image link is invalid.";
                 } else {
                     echo "Uh oh, unrecognized error code: ";
                     echo $result['ERRCODE'];
                 }
             }
         } else {
             /* Commit to database */
             OCICommit($db_conn);
         }
Example #4
0
{
    mysqli_query($conn, "CREATE TABLE IF NOT EXISTS images(\n            id INT AUTO_INCREMENT PRIMARY KEY,\n            title VARCHAR(50),\n            path VARCHAR(200),\n            description TEXT,\n            category_id INT\n        )");
    mysqli_query($conn, "CREATE TABLE IF NOT EXISTS categories(\n            id INT AUTO_INCREMENT PRIMARY KEY,\n            category VARCHAR(50)\n        )");
    mysqli_query($conn, "CREATE TABLE IF NOT EXISTS hashtags(\n            id INT AUTO_INCREMENT PRIMARY KEY,\n            tag VARCHAR(50)\n        )");
    mysqli_query($conn, "CREATE TABLE IF NOT EXISTS i_d(\n            image_id INT,\n            tag_id INT\n        )");
}
// $image= $_FILES['image'];
// echo $image['tmp_name'];
// echo '<br>';
function save_image($image)
{
    $tmp_name = tempnam('public', 'img');
    copy($image['tmp_name'], $tmp_name);
    // echo $tmp_name;
    // echo '<br>';
    return $tmp_name;
}
// $save_image= save_image($image);
function insert_path_image($tmp_name)
{
    $new_tmp = str_replace('\\', '/', str_replace(getcwd(), '', $tmp_name));
    return $new_tmp;
}
// echo insert_path_image($tmp_name);
// echo '<br>';
function insert_image($conn)
{
    mysqli_query($conn, "INSERT INTO images ( title, path, description, category_id)\n         VALUES ( 'aa', 'bb', 'cc', 1)            \n        ");
}
var_dump(insert_image($conn));
echo '<br>';
Example #5
0
    $sujet = stripslashes($sujet);
    //echo"04-requete recuperation elements = $req<br>";
}
if ($modification == 'modification') {
    /*
         Traitement de l'image n°1
    */
    $num_article;
    $num_image = '1';
    insert_image($num_article, $num_image);
    /*
         Traitement de l'image n°2
    */
    $num_article;
    $num_image = '2';
    insert_image($num_article, $num_image);
    /* Apres traitement des images, on fait un update dans la table article */
    /* Traitement des niveaux de confidentialite ou de la liste de diffusion*/
    if ($choixconf == 'diff') {
        $nivo_conf = 0;
    } else {
        $nomliste = null;
    }
    if ($lien_1_type == 'rien') {
        $lien_1_cont = null;
        $lien_1_txt = null;
    }
    if ($lien_2_type == 'rien') {
        $lien_2_cont = null;
        $lien_2_txt = null;
    }
Example #6
0
    $Q = "insert into images (property_id, location, image) values (\n\t\t\t " . $property_id . ",\n\t\t\t'" . $location . "',\n\t\t\t'" . $image . "'\n\t\t\t)\n\t\t\ton duplicate key update\n\t\t\tproperty_id\t=  " . $property_id . ",\n\t\t\tlocation\t= '" . $location . "',\n\t\t\timage\t\t= '" . $image . "'";
    execute($db, $Q, "index.insert_image.1");
}
// Put the contents of the array into the database
if (0) {
    foreach ($p as $property) {
        // Insert the entry
        // Insert the entry
        $Q = "insert into properties (title, pdf, sal_auc, front_page, text, directory, status) values (\n\t\t\t\t\"" . $property['title'] . "\",\n\t\t\t\t\"" . $property['pdf'] . "\",\n\t\t\t\t\"" . strtoupper($property['sal_auc']) . "\",\n\t\t\t\t 'Yes',\n\t\t\t\t\"" . addslashes($property['text']) . "\",\n\t\t\t\t '" . $property['directory'] . "',\n\t\t\t\t 'Not Sold'\n\t\t\t\t)\n\t\t\t\ton duplicate key update\n\t\t\t\tpdf \t\t= \"" . $property['pdf'] . "\",\n\t\t\t\tsal_auc \t= \"" . strtoupper($property['sal_auc']) . "\",\n\t\t\t\tfront_page \t=  'Yes',\n\t\t\t\ttext \t\t= \"" . addslashes($property['text']) . "\",\n\t\t\t\tstatus \t\t=  'Not Sold'";
        execute($db, $Q, "index.1");
        $property_id = mysql_insert_id();
        // Insert the images
        for ($i = 1; $i < 5; $i++) {
            $im = "image" . $i;
            if (isset($property[$im]) && strlen($property[$im]) > 0) {
                insert_image($db, $property_id, 'front_page', $property[$im]);
            }
        }
    }
    // Sort the array alphabetically according to the keys
    ksort($p);
    //Get the data out of the database
} else {
    $Q = "select \t*\n\t\t\tfrom \tproperties\n\t\t\twhere \tfront_page \t= 'Yes'\n\t\t\tand\t\tvisible \t= 'Yes'\n\t\t\torder\tby sal_auc, title asc";
    if (!($res = mysql_query($Q, $db))) {
        report_error($db, "display_properties.1" . $Q, $Q);
    } else {
        if (mysql_num_rows($res) > 0) {
            $p = array();
            $i = 0;
            while ($row = mysql_fetch_array($res)) {
function fbe_facebook_sdk($facebook_page,$appID,$appSecret){


		FacebookSession::setDefaultApplication($appID,$appSecret);

		$session = FacebookSession::newAppSession();

		try {
			  $session->validate();
		} 
			
		catch (FacebookRequestException $ex) {
			echo $ex->getMessage();
		} 
			
		catch (\Exception $ex) {
			echo $ex->getMessage();
		}


		$i=0;
		$u=0;


		try{

			$eventResponse = (new FacebookRequest($session, 'GET', '/'.$facebook_page.'/events?fields=place,cover,attending_count,description,end_time,id,name,owner,start_time,ticket_uri,timezone&limit=99'))->execute()->getResponse();
			$events = $eventResponse->data;

			foreach ($events as $e) {	
				$session = FacebookSession::newAppSession();
				$venue = (new FacebookRequest($session, 'GET', '/'.$facebook_page.'?fields=phone,photos,username,about,category,cover,emails,general_info,general_manager,location,website&limit=99'))->execute()->getResponse();

				$startDate = $e->start_time;
				$endDate = $e->end_time;
				$timezone = $e->timezone;

				// Convert time for myEventON
				$c_evcal_srow = date("U",strtotime($startDate));
				$c_evcal_erow = date("U",strtotime($endDate));
				$custom_year = date("U",strtotime($StartDate));
				$c_event_year = gmdate("Y", $custom_year);
				//
				
				$category = $e->owner->category;


				$event_id = $e->id;
				$eId = wp_strip_all_tags($e->id);	
				$city = $e->place->location->city;
				$state = $e->place->location->state;
				$zip = $e->place->location->zip;
				$street = $e->place->location->street;
				$region = $e->place->location->region;
				$country = $e->place->location->country;
				$ticket_uri = $e->ticket_uri;
				$eventImage = $e->cover->source;
				$name = $e->place->name;
				$fb_event_uri = 'https://www.facebook.com/events/'.$event_id;
				$lat = $e->place->location->latitude;
				$long = $e->place->location->longitude;

				$venue_name = $e->place->name;
				$venue_phone = $venue->phone;
				$venue_desc = $venue->about;
				$emails = $venue->emails;
				$username = $venue->username; 
				$emailAddress = $emails[0];
				$venue_website = $venue->website;	
				$event_tag = $venue->category;	

				////PRINT
				////$posts_array = get_posts('post_type=post_title');
				////print_r($posts_array);
				//print_r($e->place->name);
				////PRINT
	
				if($state){
					$state = $state.'&nbsp;';
				}
				if($street){
					$street = $street.',&nbsp;';
				}
				if($city){
					$city = $city.',&nbsp;';
				}
				if($country){
					$country = $country.'&nbsp;';
				}
				if($region){
					$region = $region.'&nbsp;';
				}
				 if($zip){
					$zip = $zip.'&nbsp;';
				}

				$location = $street.$city.$state.$zip.$country.$region ;
				$location = str_replace('<<not-applicable>>', '', $location);
				if($location == '&nbsp;' || $location == '' ){
				$location = getaddress(get_fbe_field($lat),get_fbe_field($long));
				}


				$args = array (
				'post_type' => 'facebook_events',
				'posts_per_page' => -1,
				'meta_key' => 'facebook_event_id',
				'meta_query' => array(
						'key'		=> 'facebook_event_id',
						'value'		=> $event_id,
					),
				);
				
				$loop = new WP_Query( $args );
			    if( $loop->have_posts() ){ 
					$u++;	
					while ( $loop->have_posts() ) : $loop->the_post();
						
					  $post_id = get_the_ID();
					  $curEventImage = get_post_meta( $post_id, 'image_url', true );
					  $post_information = array(
							'post_type' => 'facebook_events',
							'ID' => $post_id,
							'post_title' => wp_strip_all_tags($e->name),
							'post_content' => wp_strip_all_tags($e->description),
							'tags_input' => $event_tag,
						);
						 
						if($eventImage != $curEventImage ){insert_image($eventImage,$post_id); }
						 
						wp_update_post( $post_information );
						
					endwhile;
				}
				else
				{ 
				$post_information = array(
					'post_type' => 'facebook_events',
					'post_title' => wp_strip_all_tags($e->name),
					'post_content' => wp_strip_all_tags($e->description),
					'post_status' => 'publish',
					'tags_input' => $event_tag,
				);		
	        
			 $post_id = wp_insert_post( $post_information ); 
			 insert_image($eventImage,$post_id); 
	           

			}
			/*	$i++;

				update_post_meta($post_id,'event_timezone',$timezone);
				update_post_meta($post_id,'start_time',$startDate);
				update_post_meta($post_id,'event_starts',$startDate);
				update_post_meta($post_id,'event_starts_sort_field',$startDate);
				update_post_meta($post_id,'event_ends',$endDate);
				update_post_meta($post_id,'end_time', $endDate);
				update_post_meta($post_id,'facebook_event_id', $eId);
				update_post_meta($post_id,'location',$location);
				update_post_meta($post_id,'ticket_uri',$ticket_uri);
				update_post_meta($post_id,'fb_event_uri',$fb_event_uri);
				update_post_meta($post_id,'geo_latitude',$lat);
				update_post_meta($post_id,'geo_longitude',$long);			
				update_post_meta($post_id,'venue_email',$emailAddress);	
				update_post_meta($post_id,'venue_phone',$phone);	
				update_post_meta($post_id,'venue_website',$website);
				update_post_meta($post_id,'facebook','https://facebook.com/'.$username);
				update_post_meta($post_id,'venue_desc',$venue_desc);
				update_post_meta($post_id,'venue_name',$venue_name);
				*/
			
				/////////////////////////////////////
				// Get the Old Post
				$old_post = get_post( $post_id );

				//$my_post_meta = get_post_meta($post_id, 'image_url', true);
				
				
				$args = array(
					'numberposts' => 1,
					'order'=> 'DESC',
					'post_mime_type' => 'image',
					'post_parent' => $post->ID,
					'post_type' => 'attachment'
					);

				$get_children_array = get_children($args,ARRAY_A);  //returns Array ( [$image_ID]... 
				$rekeyed_array = array_values($get_children_array);
				$child_image = $rekeyed_array[0];  

				// Show Facebook Events ID & Title
				echo "FB_Id		-$post_id<br>";
				echo "FB_Title	-$old_post->post_title <br>";


				//print_r($child_image);  	//Show the contents of the $child_image array.
				//echo "Show the $child_image ID";
				echo "Image_Id   -";
				echo $child_image['ID'];   	//Show the $child_image ID.
				echo "<br>";
				
				$post_image_media = get_post_meta($child_image['ID'], '_wp_attached_file', true);
				echo "Media_file - $post_image_media <br>"; //image location 2015/08/11800415_396471520542665_8991308386259432158_n142.jpg
				
				
				
				
				
				
				$new_post = array(
					'post_status'    => 'publish',
					'menu_order'     => $old_post->menu_order,
					'post_type'      => 'ajde_events',
					'comment_status' => $old_post->comment_status,
					'ping_status'    => $old_post->ping_status,
					'pinged'         => $old_post->pinged,
					'post_author'    => $old_post->post_author,
					'post_category'  => $old_post->post_category,
					'post_content'   => $old_post->post_content,
					'post_excerpt'   => $old_post->post_excerpt,
					'post_name'      => $old_post->post_name,
					'post_parent'    => $old_post->post_parent,
					'post_password'  => $old_post->post_password,
					'post_title'     => $old_post->post_title,
					'tags_input'     => $old_post->tags_input,
					'to_ping'        => $old_post->to_ping,
					'tax_input'      => $old_post->tax_input,
				);
				
				$new_post_id = wp_insert_post( $new_post ); 
				/////////////////////////////////////////
				update_post_meta($new_post_id,'_thumbnail_id', $child_image['ID']);
				
				echo "New_Post_Id- $new_post_id<br>";
				echo "$new_post_id - _thumbnail_id - ";
				echo $child_image['ID'];
				echo "<br>";
				echo "______________________ <br><br>";
				
				$i++;
				/*
				update_post_meta($new_post_id,'evcal_event_color', 206177);
				update_post_meta($new_post_id,'evcal_location', $location);
				update_post_meta($new_post_id,'evcal_location_name', $venue_name);
				update_post_meta($new_post_id,'evcal_name_over_img', no);
				//	update_post_meta($new_post_id,'evcal_organizer', HHHEventOrganizerNameHHH);
				//	update_post_meta($new_post_id,'evcal_org_contact', $emailAddress);
				//	update_post_meta($new_post_id,'evcal_lmlink', JJJEventLinkJJJ);
				update_post_meta($new_post_id,'evcal_subtitle', $venue_desc);
				update_post_meta($new_post_id,'evcal_gmap_gen', yes);
				update_post_meta($new_post_id,'evcal_repeat', no);
				update_post_meta($new_post_id,'evcal_rep_freq', daily);
				update_post_meta($new_post_id,'evcal_rep_gap', 1);
				update_post_meta($new_post_id,'evcal_rep_num', 1);
				update_post_meta($new_post_id,'evp_repeat_rb', dom);
				update_post_meta($new_post_id,'evo_repeat_wom', none);
				update_post_meta($new_post_id,'_evcal_exlink_option', 1);
				update_post_meta($new_post_id,'evo_hide_endtime', no);
				update_post_meta($new_post_id,'evo_span_hidden_end', no);
				update_post_meta($new_post_id,'evo_year_long', no);
				update_post_meta($new_post_id,'event_year', $c_event_year);
				update_post_meta($new_post_id,'evo_evcrd_field_org', no);
				update_post_meta($new_post_id,'evo_exclude_ev', no);
				update_post_meta($new_post_id,'_cancel', no);
				update_post_meta($new_post_id,'evcal_lat', $lat);
				update_post_meta($new_post_id,'evcal_lon', $long);
				update_post_meta($new_post_id,'evcal_srow', $c_evcal_srow);
				update_post_meta($new_post_id,'evcal_erow', $c_evcal_erow);
				update_post_meta($new_post_id,'_evcal_ec_f1a1_cus', Link);
				update_post_meta($new_post_id,'_evcal_ec_f1a1_cusL', $fb_event_uri);
				update_post_meta($new_post_id,' _evcal_ec_f1_onw', yes);
				update_post_meta($new_post_id,'_evcal_ec_f2a1_cus', Buy);
				update_post_meta($new_post_id,'_evcal_ec_f2a1_cusL', $ticket_uri);
				update_post_meta($new_post_id,'_evcal_ec_f2_onw', yes);
				*/
				
				// Image
			
				
				


			
				
			}  


			$a ='';
			$c ='';
			$n ='';

			$error ='';
			if($u > 1){
				$c = $u;
				$a = $i-$u;
				$n = 'updated';
			}
			
			else
			
			{
			$c = $i;
			$n = 'imported';
			}

		} 
	
		catch(Exception $ex){

			$error  = $ex->getCode();
			$errorMsg  = $ex->getMessage();

			if($error == 100 ){
				echo '<div class="error" style="color:#222222; font-weight:700; font-size:1em; padding:10px">Error '.$error.': <a href="https://www.facebook.com/'.$facebook_page.'/events" target="_blank">'.$facebook_page.'</a>. <i> Country or age restricted material. Check your app settings.</i> </div>';
			}
			
			else if ($error == 102){	
				echo '<div class="error" style="color:#222222; font-weight:700; font-size:1em; padding:10px">Error '.$error.': Session key invalid or no longer valid.</div>';
			}
			
			else
				
			{
				echo '<div class="error" style="color:#222222; font-weight:700; font-size:1em; padding:10px">Error '.$error.'&nbsp;'.$errorMsg .'&nbsp;: Troubleshooting tip <a href="https://developers.facebook.com/docs/marketing-api/error-reference" target="_blank">View API Error Codes</a></div>';
			}

		}
		
		if($a >= 1){
			echo '<div class="updated" style="color:#222222; font-weight:700; font-size:1em; padding:10px">'.$a. ' events added</div>';
		}
		
		if($i > 1){
			echo '<div class="updated" style="color:#222222; font-weight:700; font-size:1em; padding:10px">'.$c . ' events '.$n.'</div>';
		}
		
		else if($i == 0){
			 if($error != 100){
			 echo '<div class="updated" style="color:#222222; font-weight:700; font-size:1em; padding:10px">There are <b>no upcoming</b> events to import at <a href="https://www.facebook.com/'.$facebook_page.'/events" target="_blank">'.$facebook_page.'</a></div>';
				}
		}
		
		else
		
		{
			echo '<div class="updated" style="color:#222222; font-weight:700; font-size:1em; padding:10px">'.$c . ' event '.$n.'</div>';
		}

	}
Example #8
0
<?php

// page title - if undefined the site title is displayed by default
$page_title = 'Images';
$images_per_page = 12;
// upload image
if (isset($_POST['upload_image']) && $_POST['upload_image'] == 'upload') {
    $upload_status = insert_image();
    if (is_int($upload_status)) {
        header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=images&image_id=' . $upload_status);
    } else {
        $error = $upload_status;
    }
}
// update image details
if (isset($_POST['update']) && $_POST['update'] == 'update details') {
    $image_id = (int) $_POST['image_id'];
    if (!empty($image_id)) {
        $update_status = update_image($image_id);
        if ($update_status == true) {
            header('Location: ' . $url);
        } else {
            $error = $update_status;
        }
    }
}
// insert image details -  for rogue images
if (isset($_POST['insert']) && $_POST['insert'] == 'insert details') {
    $insert_status = insert_image_details($_POST);
    if ($insert_status == true) {
        header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=images&image_id=' . $insert_status);
Example #9
0
<?php

include "../model/imagedb.php";
if ($_POST['method'] == "insert") {
    insert_image();
}
if ($_POST['method'] == "getAll") {
    get_all_images();
}
if ($_POST['method'] == "getImage") {
    get_images();
}
if ($_POST['method'] == "getUserImage") {
    get_user_images();
}
if ($_POST['method'] == "updateImage") {
    changeImgInfo();
}
if ($_POST['method'] == "del") {
    //echo json_encode("ha");
    delect_images();
}
if ($_POST['method'] == "like") {
    insert_like();
}
Example #10
0
<?php

/**
 * API endpoint to insert an image
 */
require_once 'medoo.min.php';
require_once 'config.php';
require_once 'functions.php';
/**
 * Insert data into the images database
 */
function insert_image($database, $post)
{
    $database->insert('images', array('stime' => microtime(true), 'created' => date("Y-m-d H:i:s"), 'id' => $post['id'], 'deletehash' => $post['deletehash'], 'title' => $post['title'], 'description' => $post['description'], 'first_name' => $post['first_name'], 'email' => $post['email'], 'ip' => $post['ip']));
}
$post = array();
$post['id'] = isset($_POST['id']) ? clean_input(filter_var($_POST['id'], FILTER_SANITIZE_STRING), 10) : '';
$post['deletehash'] = isset($_POST['deletehash']) ? clean_input(filter_var($_POST['deletehash'], FILTER_SANITIZE_STRING), 20) : '';
$post['title'] = isset($_POST['title']) ? clean_input(filter_var($_POST['title'], FILTER_SANITIZE_STRING), 140) : '';
$post['description'] = isset($_POST['description']) ? clean_input(filter_var($_POST['description'], FILTER_SANITIZE_STRING), 640) : '';
$post['first_name'] = isset($_POST['first_name']) ? clean_input(filter_var($_POST['first_name'], FILTER_SANITIZE_STRING), 140) : '';
$post['email'] = isset($_POST['email']) ? clean_input(filter_var($_POST['email'], FILTER_SANITIZE_EMAIL), 140) : '';
$post['ip'] = isset($_SERVER['REMOTE_ADDR']) ? clean_input(filter_var($_SERVER['REMOTE_ADDR'], FILTER_SANITIZE_STRING), 45) : '';
insert_image($database, $post);
/* Generate jSON output */
$output = array();
$output['OK'] = "It's OK";
generate_json_output($output);