I am writing an Extension for the original 3.3. Since the files will only change, the module consists of only a filename.ocmod.xml file. But when installing the extension, no files are changed, but no installation errors occur. What have I done wrong?
It's my XML file
https://drive.google.com/file/d/1lR2_aRPtZ5Eve54jG6D-Rr0WlSxiIvdT/view?usp=sharing
Should not use multiple lines of search operation... I just modified your file
try this after installation do not forget to refresh it in the modification
<?xml version="1.0" encoding="utf-8"?>
<modification>
<code>order_map</code>
<name>Order map</name>
<version>1.0</version>
<author>Kolesnikov Roman</author>
<link>https://opencart2x.ru</link>
<file path="admin/view/template/sale/order_list.tpl">
<operation>
<search><![CDATA[
<?php echo $footer; ?>
]]></search>
<add position="before"><![CDATA[
<!-- markup disable price -->
<script src="https://api-maps.yandex.ru/2.1/?lang=ru-RU" type="text/javascript"></script>
<script type="text/javascript">
var myMap;
ymaps.ready(init); // Ожидание загрузки API с сервера Яндекса
function init () {
var myMap = new ymaps.Map('map', {
center: [53.919166, 27.592527],
zoom: 10
}, {
searchControlProvider: 'yandex#search'
}
),
objectManager = new ymaps.ObjectManager({
clusterize: true,
gridSize: 32
});
objectManager.objects.options.set('preset', 'islands#greenDotIcon');
objectManager.clusters.options.set('preset', 'islands#greenClusterIcons');
myMap.geoObjects.add(objectManager);
objectManager.add(<?php echo $addresses ?>);
}
</script>
<div id="map" style="width: 100%; height: 500px"></div>
<!-- end markup disable price -->
]]></add>
</operation>
</file>
<file path="admin/controller/sale/order.php">
<operation>
<search><![CDATA[
$results = $this->model_sale_order->getOrders($filter_data);
]]></search>
<add position="after"><![CDATA[
$addresses = "";
function curl_get_contents($url){
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
$features = '';
foreach($results as $result){
if(!empty($result['shipping_address_1'])){
$url = 'https://geocode-maps.yandex.ru/1.x/?format=json&geocode='.$result['shipping_address_1'];
$response = json_decode(curl_get_contents($url), true);
$point = $response['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos'];
$point = explode(' ', $point);
$point = implode(', ', array_reverse($point));
$features .= '{
"type": "Feature",
"id": '.$result['order_id'].',
"geometry": {"type": "Point", "coordinates": ['.$point.']},
"properties": {"balloonContent": "'. $result['shipping_address_1'] .'", "clusterCaption": "", "hintContent": "", "iconCaption": "'. $result['order_id'] .'"}
},';
}
$addresses = '{
"type": "FeatureCollection",
"features": ['.$features.']
}';
}
]]></add>
</operation>
</file>
<file path="admin/controller/sale/order.php">
<operation>
<search><![CDATA[
'shipping_code' => $result['shipping_code'],
]]></search>
<add><![CDATA[
'shipping_address' => $result['shipping_address_1'],
]]></add>
</operation>
</file>
<file path="admin/controller/sale/order.php">
<operation>
<search><![CDATA[
$data['button_ip_add'] = $this->language->get('button_ip_add');
]]></search>
<add><![CDATA[
$data['addresses'] = $addresses ? $addresses : "{}";
]]></add>
</operation>
</file>
<file path="admin/model/sale/order.php">
<operation>
<search><![CDATA[
$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
]]></search>
<add><![CDATA[
$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.shipping_address_1, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
]]></add>
</operation>
</file>
Hope this answer might helpful to you
Related
I want to add a sub menu in OpenCart, under catalog menu in admin area.
in past we used ocmod or vqmod for do this,
an example by ocmod is here:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<code>submenu5</code>
<name>submenu5</name>
<version>2.3</version>
<author>codertj</author>
<link>codertj.com</link>
<!-- edit header controller -->
<file path="admin/controller/common/column_left.php">
<!-- create link to your page -->
<operation error="log">
<search><![CDATA[if ($this->user->hasPermission('access', 'catalog/product')) {]]></search>
<add position="before"><![CDATA[
if ($this->user->hasPermission('access', 'catalog/product')) {
$catalog[] = array(
'name' => $this->language->get('text_hello_world'),
'href' => $this->url->link('report/helloworld', 'token=' . $this->session->data['token'], true),
'children' => array()
);
}
]]></add>
</operation>
</file>
<!-- edit header template -->
<file path="admin/language/en-gb/common/column_left.php">
<operation error="log">
<search><![CDATA[$_['text_product']]]></search>
<add position="before"><![CDATA[
$_['text_hello_world'] = 'Hello World';
]]></add>
</operation>
</file>
</modification>
Now opencart use of Events system, but I can't find solution for convert this ocmod to event!
You can do that in this way,
We assume that you have recorded the event in the database, if you did not do this, you can create it quickly with the following query:
INSERT INTO `oc_event` (`code`, `trigger`, `action`, `status`) VALUES ('mymodule', 'admin/view/common/column_left/before', 'extension/module/mymodule/addSubmenu', 1)
admin\controller\extension\module\mymodule.php
<?php
class ControllerExtensionModuleMymodule extends Controller {
public function addSubmenu(&$route = false, &$data = false, &$output = false){
$my_language = $this->load->language('extension/module/mymodule');
$data['menus'][1]['children'][] = array(
'name' => $my_language['text_hello_world'],
'href' => $this->url->link('report/helloworld', 'token=' . $this->session->data['token'], true),
'children' => array()
);
}
}
admin\language\en-gb\extension\module\mymodule.php
<?php
$_['text_hello_world'] = 'Hello World!';
I tested this with OpenCart 2.3
How to add admin menu entry for Opencart 3x under a given admin menu item using events
This current topic is about injecting a submenu item above the Catalog -> Products link
Delete the event if it exists, register the event (in your extension on install maybe)
Option A: use Opencart's method
$this->load->model('setting/event');
$this->model_setting_event->deleteEvent('MY_EVENT');
$this->model_setting_event->addEvent('MY_EVENT', 'admin/view/common/column_left/before', 'extension/module/MY_EXTENSION/ADDTOADMINMENU');
Option B: inject your code in the database from an Opencart model (or even from a controller function if you don't care that much about MVC):
$this->db->query("
INSERT INTO
`oc_event`
(`code`, `trigger`, `action`, `status`, `sort_order`)
VALUES
('MY_EVENT', 'admin/view/common/column_left/before', 'extension/module/MY_EXTENSION/ADDTOADMINMENU', 1, 0)
");
Option C: run this query on the Opencart database (from phpMyAdmin, Adminer, etc.):
INSERT INTO
`oc_event`
(`code`, `trigger`, `action`, `status`, `sort_order`)
VALUES
('MY_EVENT', 'admin/view/common/column_left/before', 'extension/module/MY_EXTENSION/ADDTOADMINMENU', 1, 0)
Add the event public function to your extension
public function ADDTOADMINMENU(&$route, &$data){
/**
* Check if current logged in user has permission to access that link
* Replace "extension/module/MY_EXTENSION" with your target path
* This check can very well be ignored/deleted...
**/
if ($this->user->hasPermission('access', 'extension/module/MY_EXTENSION')) {
$my_menu_entry = array(
'id' => 'menu-MY_EXTENSION',
'icon' => 'fa-check',
'name' => 'My menu entry',
'href' => $this->url->link('extension/module/MY_EXTENSION', 'user_token=' . $this->session->data['user_token'], true),
'children' => array()
);
$target_menu_id = 'menu-catalog';
$target_submenu_href = $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'], true);
$new_menu = array();
foreach( $data['menus'] as &$menu ) {
if( $menu['id'] == $target_menu_id ) {
$new_submenu = array();
foreach( $menu['children'] as $submenu ) {
if( $submenu['href'] == $target_submenu_href ) {
$new_submenu[] = $my_menu_entry;
$new_submenu[] = $submenu;
} else {
$new_submenu[] = $submenu;
}
}
$menu['children'] = $new_submenu;
$new_menu[] = $menu;
} else {
$new_menu[] = $menu;
}
}
$data['menus'] = $new_menu;
}
}
I am new to Opencart, and it's really amazing.
I just want to insert an image in database but I am not able to upload. Here is what I've done.
Template:
<div class="col-sm-10">
<img src="" name="image" id="image" style="width: 26%;height: 100px;" >
<input type="file"
name="photo"
value="<?php echo $photo; ?>"
placeholder="<?php echo $entry_photo; ?>"
id="photo"
onChange="PreviewImages();"/>
<?php if ($error_photo) { ?>
<div class="text-danger"><?php echo $error_photo; ?></div>
<?php } ?>
</div>
Controller:
if (is_uploaded_file($this->request->files['photo']['tmp_name'])) {
$handle = fopen($this->request->files['photo']['tmp_name'], "r");
// If we know there is only a 10 chars PIN per line
// it is better to lower the expected line length
// to lower the memory consumption...
while (($pins = fgetcsv($handle, 50, ",")) !== false) {
$data['photo'][] = $pins; // there is only one PIN per line
}
fclose($handle);
} else {
$data['photo'] = array();
}
Model:
$this->db->query("
INSERT INTO " . DB_PREFIX . "customer
SET customer_group_id = '" . (int)$customer_group_id . "',
store_id = '" . (int)$this->config->get('config_store_id') . "',
firstname = '" . $this->db->escape($data['firstname']) . "',
lastname = '" . $this->db->escape($data['lastname']) . "',
photo = '" . $this->db->escape($data['photo']) . "',
date = '" . $this->db->escape($data['date']) . "',
email = '" . $this->db->escape($data['email']) . "',
telephone = '" . $this->db->escape($data['telephone']) . "',
fax = '" . $this->db->escape($data['fax']) . "',
custom_field = '" . $this->db->escape(isset($data['custom_field']['account']) ? serialize($data['custom_field']['account']) : '') . "',
salt = '" . $this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "',
password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "',
newsletter = '" . (isset($data['newsletter']) ? (int)$data['newsletter'] : 0) . "',
ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "',
status = '1',
approved = '" . (int)!$customer_group_info['approval'] . "',
date_added = NOW()
");
$customer_id = $this->db->getLastId();
Opencart 2.0
"I just want to insert an image in db but i am not able to upload. Here is what I've done."-Sruthi
Need to change 3 files
oc2\catalog\view\theme\default\template\account\register.tpl
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-telephone">Upload Image</label>
<div class="col-sm-10">
<button type="button" id="uploadimage" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-default"><i class="fa fa-upload"></i> Upload Image</button>
<input type="hidden" name="custom_field" value="" />
<input type="hidden" name="photo" />
<div id="demo"></div>
</div>
</div>
<script type="text/javascript"><!--
$('button[id^=\'uploadimage\']').on('click', function() {
var node = this;
$('#form-upload').remove();
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');
$('#form-upload input[name=\'file\']').trigger('click');
timer = setInterval(function() {
if ($('#form-upload input[name=\'file\']').val() != '') {
clearInterval(timer);
$.ajax({
url: 'index.php?route=tool/upload',
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$(node).button('loading');
},
complete: function() {
$(node).button('reset');
},
success: function(json) {
$(node).parent().find('.text-danger').remove();
if (json['error']) {
$(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
}
if (json['success']) {
alert(json['success']);
$(node).parent().find('input').attr('value', json['code']);
$(node).parent().find('input[name=photo]').attr('value', json['photo']);
document.getElementById("demo").innerHTML = '<img src="' + json['photo'] +'" width="100px" height="100px">';
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}, 500);
});
//--></script>
oc2\catalog\controller\tool\upload.php line 70
From
$json['code'] = $this->model_tool_upload->addUpload($filename, $file);
$json['success'] = $this->language->get('text_upload');
To
$json['code'] = $this->model_tool_upload->addUpload($filename, $file);
$json['success'] = $this->language->get('text_upload');
$json['photo'] = DIR_UPLOAD . $file;
oc2\catalog\model\account\customer.php
$this->db->query("INSERT INTO " . DB_PREFIX . "customer
SET customer_group_id = '" . (int)$customer_group_id . "',
store_id = '" . (int)$this->config->get('config_store_id') . "',
firstname = '" . $this->db->escape($data['firstname']) . "',
lastname = '" . $this->db->escape($data['lastname']) . "',
photo = '" . $this->db->escape($data['photo']) . "',
email = '" . $this->db->escape($data['email']) . "',
telephone = '" . $this->db->escape($data['telephone']) . "',
fax = '" . $this->db->escape($data['fax']) . "',
custom_field = '" . $this->db->escape(isset($data['custom_field']['account']) ? serialize($data['custom_field']['account']) : '') . "',
salt = '" . $this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "',
password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "',
newsletter = '" . (isset($data['newsletter']) ? (int)$data['newsletter'] : 0) . "',
ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "',
status = '1',
approved = '" . (int)!$customer_group_info['approval'] . "',
date_added = NOW()");
Ask me if you didn't understand or need something else
You did not mention in which page you are trying to upload but don't forget to add enctype="multipart/form-data" in form in case of upload.
if (is_uploaded_file($this->request->files['photo']['tmp_name'])) {
$handle = fopen($this->request->files['photo']['tmp_name'], "r");
// If we know there is only a 10 chars PIN per line
// it is better to lower the expected line length
// to lower the memory consumption...
while (($pins = fgetcsv($handle, 50, ",")) !== false) {
$data['photo'][] = $pins; // there is only one PIN per line
}
fclose($handle);
} else {
$data['photo'] = array();
}
Please replace above code by followings:
$data['photo'] = '';
$uploads_dir = 'image/data/'; // set you upload path here
if (is_uploaded_file($this->request->files['photo']['tmp_name'])) {
move_uploaded_file($this->request->files['photo']['tmp_name'],$uploads_dir.$this->request->files['photo']['name']);
$data['photo'] = $this->request->files['photo']['name'];
}
i am looking to make download files in product page without login or registration in opencart as public download link, after doing the coding am not getting the right download file and also a unknow and unformatted file is downloaded. what i get screnshot
model file
public function getProductDownloads($product_id) {
$query = $this->db->query("SELECT d.download_id, d.filename, d.mask, dd.name FROM " . DB_PREFIX . "download d LEFT JOIN " . DB_PREFIX . "download_description dd USING ( download_id ) LEFT JOIN " . DB_PREFIX . "product_to_download p2d USING ( download_id ) WHERE p2d.product_id = '" . (int)$product_id . "'");
return $query->rows;
}
public function getDownload($download_id) {
$query = $this->db->query("SELECT d.filename, d.mask, dd.name FROM " . DB_PREFIX . "download d LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) where d.download_id AND dd.download_id = '" . (int)$download_id . "'");
return $query->rows;
}
controller file
$data['downloads'] = array();
$results = $this->model_catalog_product->getProductDownloads($this->request->get['product_id']);
foreach ($results as $result) {
$data['downloads'][] = array(
'filename' => $result['filename'],
'name' => $result['name'],
'href' => $this->url->link('product/product/download', 'download_id=' . $result['download_id'], 'SSL')
);
}
/*download*/
public function download() {
$this->load->model('catalog/product');
if (isset($this->request->get['download_id'])) {
$download_id = $this->request->get['download_id'];
} else {
$download_id = 0;
}
$download_info = $this->model_catalog_product->getDownload($download_id);
if ($download_info) {
$file = DIR_DOWNLOAD . $download_info['filename'];
$mask = basename($download_info['mask']);
if (!headers_sent()) {
if (file_exists($file)) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . ($mask ? $mask : basename($file)) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
if (ob_get_level()) {
ob_end_clean();
}
readfile($file, 'rb');
exit();
} else {
exit('Error: Could not find file ' . $file . '!');
}
} else {
exit('Error: Headers already sent out!');
}
} else {
$this->response->redirect($this->url->link('common/home', '', 'SSL'));
}
}
}
view file
<?php foreach ($downloads as $download) { ?>
<?php echo $download['filename']; ?><br/>
<?php echo $download['name']; ?><br/>
download<br/>
<?php } ?>
You have to make some changes in controller file. I have changed your code. Just replace following code with download function. Hope this could help.
public function download() {
$this->load->model('catalog/product');
if (isset($this->request->get['download_id'])) {
$download_id = $this->request->get['download_id'];
} else {
$download_id = 0;
}
$download_info = $this->model_catalog_product->getDownload($download_id);
if ($download_info) {
$file = DIR_DOWNLOAD . $download_info[0]['filename'];
$mask = basename($download_info[0]['mask']);
if (!headers_sent()) {
if (file_exists($file)) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . ($mask ? $mask : basename($file)) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
if (ob_get_level()) {
ob_end_clean();
}
readfile($file, 'rb');
exit();
} else {
exit('Error: Could not find file ' . $file . '!');
}
} else {
exit('Error: Headers already sent out!');
}
} else {
$this->response->redirect($this->url->link('common/home', '', 'SSL'));
}
}`
Hey anyone can help me with this problem ?
I have this issue with my code, two files:
1 - test.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<script>
var url = "getagentids.php?param=";
function handleHttpResponse() {
if (http.readyState == 4) {
results = http.responseText.split(",");
document.getElementById('formality').value = results[0];
document.getElementById('fullname').value = results[1];
document.getElementById('sex').value = results[2];
document.getElementById('id').value = results[3];
document.getElementById('joindate').value = results[4];
document.getElementById('jobtitle').value = results[5];
document.getElementById('city').value = results[6];
document.getElementById('typeofsalary').value = results[7];
document.getElementById('contract_type').value = results[8];
}
}
function getagentids() {
var idValue = document.getElementById("email").value;
var myRandom=parseInt(Math.random()*99999999); // cache buster
http.open("GET", url + escape(idValue) + "&rand=" + myRandom, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject();
</script>
</head>
<body>
<form name="schform">
<table bgcolor="#dddddd">
<tbody>
<?php
echo $param;
include '../../../connect.php';
$db =& JFactory::getDBO();
$query = "SELECT email FROM dbemployeekpw";
$db->setQuery($query);
$result = $db->loadObjectList();
$email = $result[0];
echo " <select size='1' name='email' id='email' onChange='getagentids()' required >
<option value=''> Seleccione </option>";
foreach($result as $email)
{
echo "<option value='".$email->email."'>".$email->email."</option>";
}
echo "</select>"
?>
<tr><td>Formality</td><td><input id="formality" type="text" name="formality"></td></tr>
<tr><td>Fullname</td><td><input id="fullname" type="text" name="fullname"></td></tr>
<tr><td>Sex</td><td><input id="sex" type="text" name="sex"></td></tr>
<tr><td>Id</td><td><input id="id" type="text" name="id"></td></tr>
<tr><td>Joindate</td><td><input id="joindate" type="text" name="joindate"></td></tr>
<tr><td>Jobtitle</td><td><input id="jobtitle" type="text" name="jobtitle"></td></tr>
<tr><td>City</td><td><input id="city" type="text" name="city"></td></tr>
<tr><td>Typesalary</td><td><input id="typeofsalary" type="text" name="typeofsalary"></td></tr>
<tr><td>Contract Type</td><td><input id="contract_type" type="text" name="contract_type"> </td></tr>
<tr><td><input size="60" type="reset" value="Clear"></td><td></td>
</tr>
</tbody></table>
</form>
</body>
</html>
and..
2 - getagentids.php
<?php
//$param = $_GET["param"];
include '../../../connect.php';
$db =& JFactory::getDBO();
$query = $db->getQuery(true);
$query = "SELECT * FROM dbemployeekpw WHERE email = 'camilo.uribe#kantarworldpanel.com'";
$db->setQuery($query);
$results = $db->loadObjectList();
foreach ( $results as $result )
{
$formality = $result->formality;
$fullname = $result->fullname;
$sex = $result->sex;
$id = $result->id;
$joindate = $result->joindate;
$jobtitle = $result->jobtitle;
$city = $result->city;
$typeofsalary = $result->typeofsalary;
$contract_type = $result->contract_type;
$textout = $formality.",".$fullname.",".$sex.",".$id.",".$joindate.",".$jobtitle.",".$city.",".$typeofsalary.",".$contract_type;
}
echo $textout;
?>
But ajax dont works, only works if I put this :
$query = "SELECT * FROM dbemployeekpw WHERE email = 'camilo.uribe#kantarworldpanel.com'";
instead this:
$query = "SELECT * FROM dbemployeekpw WHERE email = '".$param."'";
But I need that the code works with second one :(
Anyone can help me with this problem ?
Thanks !!
SOLVED (works like a charm!!):
I change this:
$jinput = JFactory::getApplication()->input;
$param = $jinput->get('param', 'param', 'filter');
instead this:
$param = $_GET["param"];
and I'm still with:
$query = "SELECT * FROM dbemployeekpw WHERE email = '".$param."'";
because this code don't works for me:
$query->select($db->quoteName('*'))
->from($db->quoteName('dbemployeekpw'))
->where($db->quoteName('email') . ' = '. $db->quote($param));
Many Thanks #lodder
Before anything, lets see if the $param variable is correct and gets the value. Add the following which one the form is processed, will display the value. If the result is NULL then you firstly need to ensure you get the correct value. If you do get the correct value, then carry on reading.
Just on a side note, I would recommend looking at the following link rather than using $_GET:
http://docs.joomla.org/Retrieving_request_data_using_JInput
Lets now use up to date coding standards for you database query:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('*'))
->from($db->quoteName('dbemployeekpw'))
->where($db->quoteName('email') . ' = '. $db->quote($param));
$db->setQuery($query);
$results = $db->loadObjectList();
Hope this helps
I had a script that was working perfectly up until a couple of hours ago. This script authorizes a user, checks to see if the user is logged in, and inserts data into my database.
As of now, it fails to both identify a user or insert any data. Any help will be appreciated.
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:200px;
height:198px;
z-index:1;
left: 757px;
top: 18px;
}
-->
</style>
<div id="apDiv1"><img src="../Downloads/tree06_small.png" width="188" height="250" alt="" /></div>
<?php
require ("santatree/facebook.php");
include('login.php');
$facebook = new Facebook(array(
'appId' => 'id',
'secret' => 'secret',
));
$db_select=mysql_select_db($db_database);
if (!$db_select)
{
die ("Impossible Function". mysql_error());
}
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
if ($user) {
$token = $facebook->getAccessToken();
$friends = $facebook->api('/me/friends');
$friendsData = $friends['data'];
$User = $user['data'];
for ($i = 0; $i < sizeof($friendsData); $i++)
{
$friend = $friendsData[$i];
echo $friend['name'] . ", ";
echo $friend['id'];
echo $user['id'];
$sq1 = "INSERT into tbl_Friends (Name, FriendID, Access_ID) VALUES ('".$friend['name']."', '" .$friend['id']."', '".$user_profile['id']."')";
error_log($e);
$user = null;
}
}
mysql_query($sq1);
}
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
$access_token = $_SESSION['fb_276853929000834_access_token'];
if (!$access_token) {
echo '<script>';
echo 'top.location.href = "'.$loginUrl.'";';
echo '</script>';
} else {
// ------ Create Drop Down Name List from Friends Table ------
$myuserid = $user_profile['id'];
echo "<html>";
echo "<form enctype='multipart/form-data' method='post' action='uploadpicture1.php' name='Giftgiver'>";
$result= #mysql_query("select Friend_ID, tbl_Friends.Name from tbl_Friends inner join tbl_Users on tbl_Friends.Access_ID=tbl_Users.Access_ID where tbl_Friends.Access_ID = $myuserid");
print "<p> Select a Friend: \n";
print "<Select name=\"Friend_ID\">\n";
while ($row=mysql_fetch_assoc($result)){
$Friend_ID=$row['Friend_ID'];
$Name =$row['Name'];
print "<option value=$Friend_ID>$Name \n";
}
print "</select>\n";
print "</p>\n";
echo "Choose a gift!";
echo "<input type='file' name='GiftChoice' value='1'>";
}
echo "</form>";
echo "</html>";
?>
Have you checked to make you you have updated to Facebook's oAuth 2.0?
All FB apps and apps using the FB api are required to upgrade to oAuth 2.0 by October 1st, 2011.