oscommerce echo osc_link_object(osc_href_link problem - oscommerce

In oscommerce, I have set the DIR_WS_IMAGES from the config.php to be an external url so that the site loads the images from a static cookie-less subdomain.
The images work fine except the pop-us.
The pop-up scritp echo osc_link_object(osc_href_link(DIR_WS_IMAGES. will give the following url http://www.example.com/http://subdomain.example.com/products/originals/image.jpg which will not function as its calling main url plus the DIR_WS_IMAGES url.
How can I amend the script to just call subdomain.excample.com
Thanks for any help.
Regs Fabian
This is the code that is giving a double url [http://www.example.com/http://subdomain.example.com] that needs to be corrected to output just the [http://subdomian.example.com]
<?php
$group_id = $osC_Image->getID('originals');
echo osc_link_object(osc_href_link(DIR_WS_IMAGES.'products/'.$osC_Image->getCode($group_id).'/'.$osC_Product->getImage(),null,'AUTO',false), $osC_Image->show($osC_Product->getImage(), $osC_Product->getTitle(), null, 'product_info'), 'target="_blank" rel=""');?>
Appreciate all the help.
Regs Fab

Quickest and easiest thing to do (and won't look so out of place in osCommerce's code) is to do a preg_replace().
echo str_replace('/^http:\/\/www\.example\.com\//', '', osc_link_object(osc_href_link(DIR_WS_IMAGES.'whatever.jpg')));
Even better, dig out the global constant from includes/config.php and concatenate it in the regex - be sure to use preg_quote(SITE_BASE, '/') (assuming SITE_BASE is it, can't think of it right now off the top of my head).

May be this post can help you a bit.
http://developerblog.e-cart-solutions.com/2010/10/product-images-images-from-remote-locations/
You can simply restort to replacing the domainname by the sudomain name if the paths are no different using a simple str_replace.
Shiva

I have managed to correct the problem by simply doing
osc_link_object($link = DIR_WS_IMAGES.('products/'....
instead of
echo osc_link_object(osc_href_link(DIR_WS_IMAGES.'products/'....
Thanks to all does that offered help.
With best regards
Fabian

Related

Regex specific question and search function on my website dealing with broken links

I've been trying to figure out my regex pattern but it doesn't seem to be working for me.
Here's what i'm trying to do:
I have broken links on my website if someone accidentally gets to a page like so:
https://example.com/catalogsearch/result/?q=
or
https://example.com/catalogsearch/result/
So i'm redirecting them back to my homepage. The problem is now the search is just sending everything back to the homepage. So i'm assuming if there is something after the equals it needs to continue the search.. obviously
https://example.com/catalogsearch/result/?q=person
but currently i can't figure this out..
Here is my regex that i've been messing with for quite sometime now... still seems to be wrong or something else is wrong with my search.
"^/catalogsearch/result((/)|(/\\?)|(/\\?[a-z])|(/\\?[a-z]=))?$"
Please forgive me i'm horrible with regex.
After a lot of discussion, it is concluded that the routes.yaml will consider the url path as a valid route but not the query string part. Hence out of the two examples in the post, you can use
"/catalogsearch/result": { to: "https://example.com/", prefix: false }
and for other one please change it in nginx config to redirect to homepage or if its not possible then check with magento support on how to incorporate the query string part in routes.yaml file.

Wordpress add_rewrite_rule with 4 vars is not working

I'm trying to rewrite a url for a custom page template
The link http://pm.com/cusotm-page/7170-West-9th-Avenue-Lakewood-CO-80214/29415331/RES/METRO should be written as
http://pm.com/cusotm-page/?title=2005-South-Monroe-Street-Denver-CO-80210&ppid=29377927&property=RES&originator=METRO
the code in functions.php is
add_action( 'init', 'wpa5413_init' );
function wpa5413_init(){
add_rewrite_tag('%title%','([^&]+)');
add_rewrite_tag('%ppid%','([^&]+)');
add_rewrite_tag('%property%','([^&]+)');
add_rewrite_tag('%originator%','([^&]+)');
add_rewrite_rule('^cusotm-page-homendo/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$','cusotm-page/?title=$matches[1]&ppid=$matches[2]&property=$matches[3]&originator=$matches[4]','top');
}
can you tell me what i'm doing wrong? is the regex correct
PS" i flushed the rewrite rules and the get variables are added with add_query_arg
Ok, the solution was to use index.php with pagename on rewrite
function wpa5413_init(){
add_rewrite_tag('%title%','([^&]+)');
add_rewrite_tag('%ppid%','([^&]+)');
add_rewrite_tag('%property%','([^&]+)');
add_rewrite_tag('%originator%','([^&]+)');
add_rewrite_rule('^cusotm-page/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$','index.php?pagename=cusotm-page&title=$matches[1]&ppid=$matches[2]&property=$matches[3]&originator=$matches[4]','top');
}
this will rewrite the url and links like http://pm.com/cusotm-page/7170-West-9th-Avenue-Lakewood-CO-80214/29415331/RES/METRO would become usable.
However the $_GET['title'] will not work - but you can access variables with $wp_query->query_vars['title']
Also make sure you use add_query_arg before displaying the nice link.
Hope it helps somebody...

Regex in cfif to check there's a parameter in URL?

I'm trying to display a block of code only if the parameter ?staff is appended to URL, e.g.:
display Link only if the current URL was loaded with www.blank.com/folder/?staff
Any thoughts?
I don't believe there is any kind of performance difference, but to me it's best practices to use StructKeyExists(url,'staff') rather than isDefined("url.staff"). Either one will definitely get the job done though.
You don't need to parse the url with a regex, It should be in the url variable already if defined
<cfif IsDefined("URL.staff")>

What does this URL mean?

http://localhost/students/index.cfm/register?action=studentreg
I did not understand the use of 'register' after index.cfm. Can anyone please help me understand what it could mean? There is a index.cfm file in students folder. Could register be a folder name?
They might be using special commands within their .htaccess files to modify the URL to point to something else.
Things like pointing home.html -> index.php?p=home
ColdFusion will execute index.cfm. It is up to the script to decide what to do with the /register that comes after.
This trick is used to build SEO friendly URL's. For example http://www.ohnuts.com/buy.cfm/bulk-nuts-seeds/almonds/roasted-salted - buy.com uses the /bulk-nuts-seeds/almonds/roasted-salted to determine which page to show.
Whats nice about this is it avoids custom 404 error handlers and URL rewrites. This makes it easier for your application to directly manage the URL's used.
I don't know if it works on all platforms, as I've only used it on IIS.
You want to look into the cgi.PATH_INFO variable, it is populated automatically by CF server when such URL format used.
Better real-life example would look something like this.
I have an URL which I want to make prettier:
http://mybikesite/index.cfm?category=bicycles&manufacturer=cannondale&model=trail-sl-4
I can rewrite it this way:
http://mybikesite/index.cfm/category/bicycles/manufacturer/cannondale/model/trail-sl-4
Our cgi.PATH_INFO value is: /category/bicycles/manufacturer/cannondale/model/trail-sl-4
We can parse it using list functions to get the same data as original URL gives us automatically.
Second part of your URL is plain GET variable, it is pushed into URL scope as usually.
Both formats can be mixed, GET vars may be used for paging or any other secondary stuff.
index.cfm is using either a CFIF IsDefind("register") or a CFIF #cgi.Path_Info# CONTAINS statements to execute a function or perform a logic step.

Please advice the folder structure for Handling multiple sites in Django

alt text http://www.freeimagehosting.net/image.php?387990357b.jpg
Please see the folder structure image in the above url mentioned please advice which structure would be best suited for better code managibility. If the above image is not gettign please use this url http://www.freeimagehosting.net/image.php?387990357b.jpg
As far as automated deployment goes, It would appear to me that your second option would be better... that will allow you to "pick up" either site 1 or site 2 all at once and drop it anywhere you want.
I use virtualenv to manage multiple sites, which is basically an extension of the second option: each with their own code base and settings file and modules.
this looks good: http://www.mail-archive.com/django-users#googlegroups.com/msg75840.html