Jump to content

etrader

Members
  • Posts

    315
  • Joined

  • Last visited

    Never

Posts posted by etrader

  1. I want to assign some values for each entry. Which plan is better to assist better mysql performance

     

    Plan A: Storing as "value1-value2-value3" in a column created by varchar(50); then I can process the values by explode()

    or

    Plan B: Storing values individually in three columns created by int(11)

     

    I want to know several small int() is better OR it is better to keep the number of columns lesser by having a larger column of varchar(), as I need to add "-" separator.

  2. I insert into mysql table by a simple form. The problem is that I get error when my text contains (') or ("). Dow I need to put a \ before them by php before inserting into mysql or there's another trick to skip (') and (") when storing and calling text into/from mysql database?

  3. I capture a list of my articles from mysql by this command

    mysql_query("SELECT * FROM Text WHERE Key='$key'") 

    Now I added a column for published and draft to be identified by 1 and 0, respectively. What is the best way to show only published articles? Adding a WHERE condition? What is the most common method in major CMSes?

     

    Thanks  :shy:

  4. <?php
    echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";
    $browser = get_browser(null, true);
    print_r($browser);
    ?>
    

    should help you, but remember you should configure it on server and support him browser list.

    Reference: http://php.net/manual/en/function.get-browser.php

     

    Thanks LeadingWebDev,

    Yes this is an alternative solution, as get_browser will provide [crawler] to be true or false. But I have read some reviews on the internet as the [crawler] is not very accurate, probably because get_browser is not very popular. On the other hand, it gives lots of information which are useless to me. Then, I though using $_SERVER['HTTP_USER_AGENT'] and performing preg_match is a lighter process. What do you think?

  5. I am writing a simple counter, but it counts both visitors and bots. To distinguish between these visits, I use $_SERVER['HTTP_USER_AGENT']. By preg_match I can get which visit is by a bot. The common way in the internet is to define preg_match for each major bot (e.g. googlebot). As I explored, all bots have their official url in the uer_agent. Thus, preg_match by "http://" should consider all bots; as user_agent of a human visitor does not include a url. Right?

     

    What's your idea to do so?

  6. I want to crop a circle in the middle of a photo. To have transparency of the image around the main circle, I need to save it as PNG. Is it possible to write a php code to

     

    1. crop a full circle in the middle of a JPG file

    2. then save it with png transparency to show the main circle only?

  7. I search for words in mysql by

     

    mysql_query("SELECT * FROM Articles WHERE Tags LIKE '%$q%'", $con);

     

    But I have problem with my tags as they are stored as "tag1,tag2,tag3". Now I want to get every article which contains "tag1"; but this does not work as LIKE %tag1% needs space to detect a word; though my tag list is comma separated.

  8. It seems there is no way to do so. I am currently doing what ZulfadlyAshBurn said. I was looking for a way NOT to edit every single php file in my admin folder. I was looking to make a rule for the entire folder, not every single page.

     

    WebStyles, I did not ask you to make it work for me. I just asked you to clarify your tip, as apparently you did not get my issue.

     

    Anyway, thank folks! :)

  9. I created a session by a login page, and limited the pages by adding this condition to every page

     

    if(!isset($_SESSION['level'])){
    echo"You are not authorized to visit this page";		
    }

     

    This works perfectly for every single page, but how I can use it for an entire folder like admin folder ?

  10. I have created a very simple CMS by storing articles in mysql database. Everything is OK for my need; but I have no idea how to handle user management. I have created a table for users and a page to create new accounts.

     

    But how I can restrict the article submission page to logged in users?

    How I can show a widget of profile of logged users?

     

    I think there are different ways to do so; define(), cookie, ....

    What is the best method as CMSes normally use?

     

    Thank you in advance  ;)

  11. I want to delete everything after a given character; e.g. wanna get the first word from this string by deleting everything after first occurrence of "-"

    $str="word1-word2-word3";

    I use this trick to do so

    $str2=substr($str,0,strpos($str, '-'));

     

    This works perfectly, but the problem is when the string is just one word without the given character (i.e. "-"). It will return nothing for $str="word1";

     

  12. Following common tutorials, we usually install selected modules of php. I wonder why not installing all modules (e.g. as yum install php php-*). Are they really useless? We have lots of unused softwares on our servers; do these unnecessary php modules consumes lots of resources?

     

    On the other hand, I am curious to know what are the necessary modules of php for a normal usage?

     

     

    P.S. I think that we install most of php modules by php-common!

  13. ACL is a advanced system for creating users and user permissions stored in mysql, right?

     

    I am talking about only one admin whose login can be stored in a file too. Do you still think that php-based ACL is the best solution?

×
×
  • 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.