Jump to content

eevan79

Members
  • Posts

    240
  • Joined

  • Last visited

    Never

Everything posted by eevan79

  1. I already tried with DOM but without success. Maybe I need to look deeper... Also I found an interesting jQuery plugin, and maybe it can be usefull: http://benalman.com/code/projects/jquery-replacetext/examples/replacetext/ It replace all text but leave all tags and attributes untouched.
  2. I want to replace latin text to cirilic text. It's not so hard, but there is problem with HTML. It's also replaced. Example: $before = array("a","b","c","d"); //etc. $after = array("а","б","ц","д"); //etc. //final output *original: some text <a href="link"><img src="image" alt /></a> //final output *after: соме техт <а хреф="линк"><имг срц="имаге" алт /></а> How to replace all text but ignore HTML (not remove) ?
  3. @PFMaBiSmAd, finally solved. I activated Show All Characters and it shows CR *without LF, so I converted it Win format. Thanks.
  4. It is very strange because it never has happened. Perhaps with the new version of the program. I use Notepad++ and was looking at all options regarding text wrapping and margin boundary but any change has no effect. Still do not understand why file is saved differently - when I view page source it's all wrapped and I want to be same as I wrote. Has to do with settings options of code editor?
  5. I'm not sure that this issue belongs to this forum because of problems that do not understand. I do not know why this happens. When I look at the page source code is wrapped without spaces. It look like this: And here is source code: I know that this is not a big problem, but can be irritating, especially when looking at the page source for debugging and so on. This did not happen earlier. Does anyone know why this happens?
  6. Because, there are lots of (already) linked articles in other articles. However, I solve this and all links from Wordpress are valid (rewrited with title=LINK).
  7. Thanks. With few corrections it's working fine. $categoryFile = dirname($_SERVER['SCRIPT_FILENAME'])."/inc/cat_ids.php"; $categoryList = array(); foreach( file($categoryFile) as $line) { preg_match("#(\d+)='([^']*)'#", $line, $match); $categoryList[$match[1]] = str_replace("-", " ", $match[2]); } //$categories = $category; 1,5,23,46 $categoryIDsAry = array_map('trim', explode("," , $category)); $catsHTMLAry = array(); foreach ($categoryIDsAry as $catID) { $catSlug = $categoryList[$catID]; $catName = str_replace("-", " ", $catSlug); $catsHTMLAry[] = "<a href=\"index.php?category=$catSlug\">".strtoupper($catName)."</a> "; } $cats = implode(', ', $catsHTMLAry);
  8. Here is how I get categories for article listing. Article can be written in several categories at once. So I have this code: $category = '1,5,23,46'; //Category IDs $get_cats = explode("," , $category); $cats = ""; for ($i = 0; $i<count($get_cats); $i++ ) { $cat = trim($get_cats[$i]); $catSlug = get_value_of($cat, "inc/cat_ids.php"); $catName = str_replace("-"," ",$catSlug); $cats .= "<a href=\"index.php?category=$catSlug\">".strtoupper($catName)."</a>, "; } $cats = substr($cats,0,-2); As you can see there's get_value_of function that is used to read the category from the file. File is cat_ids.php and looks like this: I want to improve this in order not to read the file at each step ("for" loop). Means, one can load the file and then generate a list of (links) category compared to the numbers (Ids). So if $category is "1,3,4" I want to get list like this (by reading cat_ids.php): category-name-1, category name-3, category-name-4 With current function I read value for every ID from file in every step. So if article have 10 or more categories script load file 10 or more times. Looking for a solution to do this from a reading file only once. Thanks.
  9. I forgot to include code. This is what I have tried (on localhost): RewriteEngine On RewriteBase /wp/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9-]+)$ wp/index.php?title=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp/index.php [L] So if i have link like this: http://localhost/wp/test I got: title=test. But if I have more "/" or slash on the end of url I get page with wrong links (including .css etc). I just need to get "text" after last trailing slash and rewrite to title=?
  10. I try to integrate WordPress perm links into new cms (custom), so I need to make rewrite condition for old links in posts. So I have links like this: site.com/category/page-title or site.com/category/page-title/ site.com/games/text/page-title or site.com/games/text/page-title/ etc. I need to get last request uri ( url after last "/" ) and rewrite to: site.com/index.php?title=page-title I have tried various methods but nothing do not succeed.
  11. Google cant see pages with rewrite mod. Always return 404 (not found). So if my page is: site.com/page/20.html google return 404 but if page is site.com/?page&title=20 it's working fine. Why google can't index pages with rewrite mod? Here is my .htaccess RewriteRule title/(.*)\.html$ /?page&title=$1
  12. I have field "friends" 0/1 for accepted requests. @kickstart, tested and working fine. Thats query I looking for.
  13. I have USERS table and FRIENDS table. When user send friend request to other user data have been added into FRIENDS table. When other user accept request, data is also added (for his ID). There's no problem to get approved (both data) friends, but I want to get pending list. This is fields for FRIENDS table: user_id | friend_id | friends For example we have 2 users: one with ID 1, and other with ID 2. So user with ID 1 send friend request to ID 2 following data will be added into FRIENDS table: 1 | 2 | 1 When other user accept request: 2 | 1 | 1 So there is record for both users in FRIENDS table. So, how to get data only when there is one record (to get pending requests)? This is query to get friend list: SELECT z.friend_id, u.username, u.user_avatar FROM " . FRIENDS_TABLE . " AS z, " . FRIENDS_TABLE . " AS m, " . USERS_TABLE . " AS u WHERE z.friend_id= m.user_id AND m.friend_id= {$userID} AND z.user_id = {$userID} AND z.friend_id= u.user_id ORDER BY LOWER(u.username) DESC Now I need query to get pending request (those that the user has not yet approved)? [/size]
  14. I already use authentication, but I don't want to registered user access the file directly. Maybe I can use $_SERVER['HTTP_REFERER'] to check if file is called from website, instead directly. If user calls the file directly, $_SERVER['HTTP_REFERER'] will be empty. But I think that this is not enough ...
  15. I use jQuery when adding messages. However, the file can be called directly. For example: includes/add_comment.php?id=2 So, I can make a form and call this file directly to add a message. ID is user id and form can be submited with HTML form wherever are located. How to prevent direct access to the file when called through a Ajax?
  16. I am using this script: http://demos.9lessons.info/auto.htm But I revised it for my needs. I tried your solution and works ok.
  17. I have the auto suggestion script. While the user is typing, results are printed below (from the database). The results are printed with bold letters that are in the search. However, this leads to errors in capitalization. The letters are replaced by users' queries, instead of from the database. Example: Search word: PHP Results: PHPfreaks, PHP tutorials But in the database this is the records: "phpfreaks" and "php tutorials". This is a script that replaces search letters with bolded: $search = clean($_POST["search"]); $fname=$row['name']; //Record from database $re_fname='<b>'.$search.'</b>'; //Replace with bold letter $final_fname = str_ireplace($search, $re_fname, $fname); How to do a script that bold letters, but as they were in the database, not from search input?
  18. That curl is quite fast. I think a lot of speed up the process. I have yet to test. I already use a script that checks a valid link, now I use it for images. Thanks ... I wonder how I came to my mind not to use CURL for all this
  19. I have limited parser to check 5 images (and user can choose one image that will appear with submited link). Despite the fact that I limited checking for the 5 images, the process can still take a while (5-20 sec.), but sometimes lasts a few seconds. It seems that there is no other (faster) solution.
  20. I use a script for sharing links. Everything works ok, but checking for valid images can take a long time. First through CURL method I parse certain tags (for description and title) then I use the following script to find images from the submited link: $dom = new domDocument; @$dom->loadHTML('<?xml encoding="UTF-8">' . substr($content,0,35000)); $dom->preserveWhiteSpace = false; $images = $dom->getElementsByTagName('img'); It sometimes happens that the images have not not a good path(depending on whether the link is permanent or not) and then use the getimagesize function that works well. But it can be very slow ...sometimes it takes 15-30 seconds. Without function getimagesize process takes a few seconds. Is there a better (faster) method to check whether the image is valid or not?
  21. Great. It's working fine. I also added random digits in .php part, so that the image is immediately updated. Thanks MrAdam
  22. I have the upload form and when the image is added, it is displayed on the screen without refreshing the page. It works OK, but when it comes to images with the same type of display shows the previous picture (until refresh the page or click on "view/refresh image" in browser). When I upload an image from another format, then it is display correctly (eg, previous image was .jpg and the new .gif). I have tried various methods to refresh but it does not work. I tried javascript timeout to view it again but it does not display a new image. I set timeout for 5 sec to refresh the image and then call this function: function refreshIMG(link) { alert(link); document.getElementById("img").src=link; } Also tried to call this function with input button (onclick), but no results. How to refresh image in real time (after Ajax upload)? EDIT: When I click Open image in new tab (in browser) it opens new fresh image...but I cant refresh in real-time...
  23. Thanks for reply...I'll read detailed information later. Maybe it is better to use 2 queries - SELECT count(*) and DELETE FROM table ORDER BY id ASC LIMIT count . Does anyone knows a better solution?
  24. How to delete all records but keep 1000 most recent records (by ID or date whatever) in MySql database?
  25. Have you tried GROUP BY topic_id http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.