Jump to content

IThinkMyBrainHurts

Members
  • Posts

    51
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by IThinkMyBrainHurts

  1. 2. Seamlessly, do you mean successfully or concatenated together? Looking at that code they shouldn't get concatenated!

    ... Have you tried manually calling the view image page? That code looks right to me!

    3. Oops

     

    ... When testing the view page manually output some other text to verify, not the image ;)

     

     

    BTW you could you edit the initial post so tha it uses code blocks, you'll be surprised how much easier it is to spot issues when properly indented...

  2. Hi, I've written a CMS, works fine on my Linux dev OS. I've just setup WAMP on a Win machine and it's complaining at this:

     

     

    <?php
    define('NUBBASE', 'http://localhost/cms/site/');
    define('NUBDIR', 'C:\wamp\www\cms\site\');
    
    function rx_settings(){
        return array ('sitename' => 'mysite.co.uk',
      'sitetag' => 'Developing minds...',
      'db_host' => 'localhost',
      'db_uname' => 'testuser',
      'db_pass' => 't3st3rspasSw0rd',
      'db_dbname' => 'dbtest',
      'db_prefix' => 'nub_',
      'sitesalt' => 'rxWhsqSkWk'
    );
    }
    ?>
    

     

    Thisis the error I'm getting:

     

    Parse error: syntax error, unexpected 'sitename' (T_STRING) in C:\wamp\www\cms\site\nub\config.php on line 6
    

     

    Line 6 is the line with "sitename" on.

    I've tried swapping the quotes, gone through and replaced all line endings.

     

    What's going wrong here? Any other things I could expect?

     

    Cheers

  3. I'd hazzard a guess that early on when you use:

         if(strpos($strTypes, 'bidDate') !== false){
    

    that its coming back as false, so the query string is not made, you then don't check for an empty query string, hence:

    $select_c = sqlsrv_query( $conn, $sql);
    

    returns false since no query string, then:

    sqlsrv_fetch_array(...
    

    throws an error since $select_c is not a resource but a boolean false...
     
    As the manual for sqlsrv_query() states:
    Returns a statement resource on success and FALSE if an error occurred.

    Which sounds like your reported error!?

  4. Glob searches filenames within the current directory... it doesn't search within a file...???

     

    Why strpos, why not use preg_grep? (simpler, better results, can do all at once, but maybe slightly slower)

     

    As for common shells... nothing wrong with them since most applications are written in C, e.g. glob.

     

     

     

    Can you simplify your question? Are you just wanting to know to best (fastest or memory efficient) way to search files?

    Should the search be optimised for memory or speed?

  5. Game security...
     
    Yes IMO it should virtually all be handled on the server. The concept is known as an Authoritative Game Server. In short, the client makes an input, this is sent to the server, the server processes the input, updates the scene data. Then the client app checks back for the result. In many cases the input is sent to the server, however the client app also processes the input and a result happens (e.g. character moves). Then the client will request the scene and test it against what it has, if what it has is wrong then it resets to the new server issued data. In reality the server doesn't care what the client see's, it just processes the input with the server side data (it also controls the enemy units too).

     

    As for the server controlling the AI, in general it'll calculate that on the next update / input request, using elapsed time as a factor.

     

     

    @ignace, a while back I tried to make a secure JS game, but no matter what I tried I could always access and insert into the JS of the page (dynamically loaded or not)

  6. I started a project like this a year or so ago.

     

    Basically i've written an interface for adding words and their type(s), and manually added the entries... IMHO scraping would be either illegal or just not in the spirit of things.

     

    One way I add words is by parsing sample text and identifying the unknown words, which I then work through.

     

     

    To the DB, there's two tables (actually 3), one for the words (id,word,word2,added,user,status) and another for the lists (id,word_id,type,added,user,status). Third is for training content.

     

    Obviously the word goes in the word tables word entry, then for the selected word types associated with the word get their own entry in the list table.

    * I have separate entries for plurals, etc (even though it can recognise plurals, prefixes, etc)

    * word2 is an ordered version of the word for quicker anagram solving.

     

    Here's a list of word types i'm using so far (there is another list which groups these)

    $wordtypes=array("adjective","adjective_continent","adjective_personality_negative","adjective_personality_positive","adverb","adverb_completeness","adverb_frequency","adverb_how","adverb_manner","adverb_place","adverb_purpose","adverb_time","adverb_time_frequency","adverb_time_frequency_indef","adverb_time_point","adverb_time_relationship","adverb_what_extent","adverb_when","adverb_where","contraction_informal","interjection","noun","noun_continent","noun_country","noun_fruit","noun_names_boys_eng","noun_names_girls_eng","noun_names_unisex_eng","noun_surname_eng","prefix","preposition","pronoun","question_words","stopword","suffix_derivational","suffix_inflectional","verb","verb_regular",
    	"plural","noun_phrase","verb_participle","verb_transitive","verb_intransitive","conjunction","definite_article","indefinite_article","nominative");
    
    I can't currently tell you how many words I have because I've re-installed my OS recently and haven't got around to re-installing my word DB yet. But I believe I have around 10,000 words. It may not seem like many (and it's not) but it is enough to parse most children's books which was my reason for doing this.

     

    One helpful (even though baffling at first) book I have is:

    http://www.amazon.co.uk/Finite-state-Language-Processing-Speech-Communication/dp/0262181827/ref=sr_1_1?&keywords=finite-state+language+processing

    but a great one for the shelf is:

    http://www.amazon.co.uk/Structure-Magic-About-Language-Therapy/dp/0831400447/ref=sr_1_1?keywords=the+structure+of+magic

    The latter book is nothing to do with computer programming but rather NLP

     

    Both will help with the understanding of the structures of sentences. May I also point out, English may be one of the harder languages because of all the beautiful ambiguities.

  7. In your case a media query may look like this:

     

    #header_container{
        background-image:url('../images/studyingthepast_smaller_banner.png');
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-size: 100% auto;
        color:#F3F3F3;
    }
    
    header{
        width:950px;
        height:339px;
    }
     
    @media screen and (max-width:760px){
       header{
           width:475px;
           height:170px;
       }
    }
    
     

    See: http://www.w3schools.com/cssref/css3_pr_mediaquery.asp

     

     

    *** Due to the size of your original image you may want to change the size at which the media query kicks in... Oh, you can have multiple media queries.

    • Like 1
  8. I read this one yesterday and what I took from requinix's link was that unlink() was the thing to use.

     

    The use of clearstatcache() to me / the manual, doesn't affect your code since you are aren't using PHP to remove the files, rather the systems shell.

     

    I am surprised that the command doesn't finish before returning. On reading the manual about shell_exec() there are no mentions of it not completing the operation before returning. The only thing I can see which may affect that is you not getting the response from shell_exec(), so maybe (just maybe) changing your first line to:

     

    $output=shell_exec("rm -r ".$_SESSION['todays_backup_dir']);
    

    But still not sure that'll do it.

     

    Personally I'd write my own recursive function in PHP and use unlink(), then you'll be sure... Also not sure if Windows systems have the "rm" command (rather RMDIR, DEL, ERASE, DELTREE), so this method would be platform independent too.

  9. Thankyou for your reply, I see where you're coming from, however you're not pulling the content from the Model, just including different prepared parts of the page.

     

    This is how far my notes / thinking extended:

     

     

    PAGE PRESENTATION
    =========================================================
    
    METHOD 1
    
        - Read in a file of HTML, string replace some tags, echo out.
        
    METHOD 2
    
        - Finally include a HTML / PHP file which dumps HTML and uses PHP functions to retrieve
            data from the Model.
    
    *** In all cases here, the Model decides which page template to use. Also Model functions
        will be used to include other files, e.g. header, footer, etc.

    * NB the Model is a singleton class with function wrappers

     

     

    lol, don't slate the markup, this was my quick demo setup (but I LOVE TABLES!!!)

     

    Here's the old demo (string replace method):

     

    <html>
    <head>
    [INCLUDES]
    </head>
    <body>
    <table class="tBasic">
    <tr><td colspan="2">[HEAD]</td></tr>
    <tr><td>[MENU]</td><td>[LOGIN]</td></tr>
    <tr><td colspan="2">[BODY_HEAD]</td></tr>
    <tr><td colspan="2">[BODY]</td></tr>
    <tr><td colspan="2">[FOOT]</td></tr>
    <tr><td colspan="2">[LOG]</td></tr>
    </table>
    </body>
    </html>
    

     

    And here's today's revision (page accesses the Model):

     

    <html>
    <head>
    <?php echo nub_block('INCLUDES'); ?>
    </head>
    <body>
    <table class="tBasic">
    <tr><td colspan="2"><?php echo nub_block('HEAD'); ?></td></tr>
    <tr><td><?php echo nub_block('MENU'); ?></td><td><?php echo nub_block('LOGIN'); ?></td></tr>
    <tr><td colspan="2"><?php echo nub_block('BODY_HEAD'); ?></td></tr>
    <tr><td colspan="2"><?php echo nub_block('BODY'); ?></td></tr>
    <tr><td colspan="2"><?php echo nub_block('FOOT'); ?></td></tr>
    <tr><td colspan="2"><?php echo nub_block('LOG'); ?></td></tr>
    </table>
    </body>
    </html>
    

     

    This will still change though, e.g. the use of echo will soon not be required and some blocks will get passed an array (of posts, menu items, etc)

     

     

     

    Oh, I looked at Smarty and Twig last night. They are a step beyond what I'm after, I don't want to introduce another syntax to learn, I want to keep it simply HTML / CSS and a touch of PHP.

  10. Hi,

     

    I'm writing a CMS, using a MVC pattern. I initially wrote the styling quickly, basically it takes a html file with some replaceable tags.

     

    Since then I've had a discussion about Wordpress and how that calls functions for the parts so that the page can process the information.

     

    This got me wondering if there are any standard approaches to the page output, templating, etc?

     

     

    Cheers

  11. Hi,

     

    I've found a menu I like and works responsively. However the CSS is written so that it affects all lists. I've tried various ways i'd expect to combine it to only work within the nav element. Here's the code (with the menu html again so as to test scope):

    <!DOCTYPE html>
    
    <html lang="en"><head>
    
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
        <meta charset="UTF-8">
    
        <title>CSS Only Navigation Menu</title>
    
        <meta name="viewport" content="width=device-width, initial-scale=1">
    
        <!--<link rel="stylesheet" href="CSS%20Only%20Navigation%20Menu_files/style.css">-->
    
        
    
    <style>
    
    /*Strip the ul of padding and list styling*/
    
    ul {
    
        list-style-type:none;
    
        margin:0;
    
        padding:0;
    
        position: absolute;
    
    }
    
    
    
    /*Create a horizontal list with spacing*/
    
    li {
    
        display:inline-block;
    
        float: left;
    
        margin-right: 1px;
    
    }
    
    
    
    /*Style for menu links*/
    
    li a {
    
        display:block;
    
        min-width:140px;
    
        height: 40px;
    
        text-align: left;
    
        line-height: 40px;
    
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    
        color: #fff;
    
        background: #2f3036;
    
        text-decoration: none;
    
        
    
        text-indent:10px;
    
    }
    
    
    
    /*Hover state for top level links*/
    
    li:hover a {
    
        background: #19c589;
    
    }
    
    
    
    /*Style for dropdown links*/
    
    li:hover ul a {
    
        background: #f3f3f3;
    
        color: #2f3036;
    
        height: 40px;
    
        line-height: 40px;
    
    }
    
    
    
    /*Hover state for dropdown links*/
    
    li:hover ul a:hover {
    
        background: #19c589;
    
        color: #fff;
    
    }
    
    
    
    /*Hide dropdown links until they are needed*/
    
    li ul {
    
        display: none;
    
    }
    
    
    
    /*Make dropdown links vertical*/
    
    li ul li {
    
        display: block;
    
        float: none;
    
    }
    
    
    
    /*Prevent text wrapping*/
    
    li ul li a {
    
        width: auto;
    
        min-width: 100px;
    
        /*padding: 0 20px;*/
    
        padding-right:20px;
    
        padding-left:10px;
    
    }
    
    
    
    /*Display the dropdown on hover*/
    
    ul li a:hover + .hidden, .hidden:hover {
    
        display: block;
    
    }
    
    
    
    /*Style 'show menu' label button and hide it by default*/
    
    .show-menu {
    
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    
        text-decoration: none;
    
        color: #fff;
    
        background: #19c589;
    
        text-align: left;
    
        padding: 10px 0;
    
        display: none;
    
    }
    
    
    
    /*Hide checkbox*/
    
    input[type=checkbox]{
    
        display: none;
    
        -webkit-appearance: none;
    
    }
    
    
    
    /*Show menu when invisible checkbox is checked*/
    
    input[type=checkbox]:checked ~ #menu{
    
        display: block;
    
    }
    
    
    
    
    
    /*Responsive Styles*/
    
    
    
    @media screen and (max-width : 760px){
    
        /*Make dropdown links appear inline*/
    
        #menu ul {
    
            position: static;
    
            display: none;
    
        }
    
        /*Create vertical spacing*/
    
        #menu li {
    
            margin-bottom: 1px;
    
        }
    
        /*Make all menu links full width*/
    
        #menu ul li, #menu li a {
    
            width: 100%;
    
        }
    
        
    
        /*Display 'show menu' link*/
    
        #menu .show-menu {
    
            display:block;
    
            /*padding-left:10px;*/
    
            text-indent:10px;
    
        }
    
        
    
        #menu .show-menu:hover{
    
            cursor: pointer; cursor: hand;
    
        }
    
        
    
    }
    
    </style>
    
    
    
    </head>
    
    <body>
    
    
    
    <nav class="nav_main">
    
        <ul>
    
            <li><a href="#">Home</a></li>
    
            <li>
    
                <a href="#">About</a>
    
                <ul class="hidden">
    
                    <li><a href="#">Who We Are</a></li>
    
                    <li><a href="#">What We Do</a></li>
    
                </ul>
    
            </li>
    
            <li>
    
                <a href="#">Portfolio</a>
    
                <ul class="hidden">
    
                    <li><a href="#">Photography</a></li>
    
                    <li><a href="#">Web & User Interface Design</a></li>
    
                    <li><a href="#">Illustration</a></li>
    
                </ul>
    
            </li>
    
            <li><a href="#">News</a></li>
    
            <li><a href="#">Contact</a></li>
    
        </ul>
    
    <nav>
    
    
    
    <br /><br /><br /><br /><br /><br /><br /><br />
    
    <ul>
    
            <li><a href="#">Home</a></li>
    
            <li>
    
                <a href="#">About</a>
    
                <ul class="hidden">
    
                    <li><a href="#">Who We Are</a></li>
    
                    <li><a href="#">What We Do</a></li>
    
                </ul>
    
            </li>
    
            <li>
    
                <a href="#">Portfolio</a>
    
                <ul class="hidden">
    
                    <li><a href="#">Photography</a></li>
    
                    <li><a href="#">Web & User Interface Design</a></li>
    
                    <li><a href="#">Illustration</a></li>
    
                </ul>
    
            </li>
    
            <li><a href="#">News</a></li>
    
            <li><a href="#">Contact</a></li>
    
        </ul>
    
    <br />
    
    
    
    <br /><br />
    
    <a href="index.html">INDEX</a><br />
    
    <br />
    
    <br />
    
    </body>
    
    </html>
    

    How do I make the CSS specifically for the main nav menu?

     

    Thanks

  12. When!

     

    Is not realising what you have not done an exscuse for being foolish?

     

    And yes there are ways of doing things, however there is always the most efficient, practical and safest way to do them!

     

    But hey we are here to learn and i've generally learnt the hard way, but at least I know why...

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