Jump to content

StirCrazy

Members
  • Posts

    75
  • Joined

  • Last visited

    Never

Posts posted by StirCrazy

  1. Hi folk,

    Need some of that 'ol phpfreaks magic :)

     

    I'm trying to contruct a page (as a whole) from lots of sub template files. Some of these sub template files call other sub template files (a bit like you would use 'include' to call a php file).

     

    I'm currently using this function, but it only constucts the page up to the first sub level template (it doesn't get templates within templates).

    function contructpage($template) {
    
    global $subdir;
    
    $templateincludes = getStrsBetween('{template:','}', $template);	
    
    if (isset($templateincludes)) {
    	foreach ($templateincludes as $value => $tplfile) {
    		if(!($includedtemplate = @file_get_contents($subdir['templates'] . '/' . $tplfile))) {
    			error('no_sub_tpl', $tplfile);
    		}
    		$template = eregi_replace('{template:' . $tplfile. '}', strval($includedtemplate), $template);
    	}
    }
    
      return $template;
    
    }
    

     

    $template = file_get_contents('main_template.tpl')
    $whole_template = contructpage($template);
    

     

     

     

    Can anyone help making a function that keeps going until the whole page is made?

     

     

     

    EG:

     

    index.tpl:-

    <header>

    <body>

    {template:file1.tpl}

    {template:file2.tpl}

    {template:file3.tpl}

    {template:file4.tpl}

    <footer>

     

     

    file1.tpl:-

    {template:subfile1.tpl}

    {template:subfile2.tpl}

     

    subfile1.tpl:-

    {template:infinity_other_tpl_files.tpl}

  2. thanks badbad :D

     

    Kinda got it working using below, but is a very dirty way of coding. There must be a patten that matches it.

     

    		$message = (str_replace('[url]http://www.' . $domain, '', $message));
    $message = (str_replace('[url=http://www.' . $domain, '', $message));
    $message = (str_replace('[url="http://www.' . $domain, '', $message));[/code]

     

    I'll give your way a go and see what happens.

  3. Hey all :D

     

    Having a little problem with pattern matching (because I'm crap at it LOL). I need to remove a variable URL from page text. Problem is the URL is wedged between bbcode.

     

    The domain variable:-

    $removedomain = "domain.com";

     

    Needs to cater for:-

    with or without http / https ://

    with or without www.

     

    EG:

    [url(.*) $domain (.*) [/url]

     

    $pagetext = (preg_replace($pattern, '', $pagetext));

     

     

     

    Can anyone help me with the correct pattern to remove the right domain?

     

     

     

    Thanks,

    S.C>

  4. Hi there,

     

    I've used stripos to find the position of part a word. How would I find the full word?

     

    EXAMPLE:

     

    $string = "this is message text  text  text  text  text  text  text  text  text  text  text";

     

    the full word at character position 10 is "message".

     

    How word I put that full word ("message") in a variable (for use later)?

     

     

    Thanks in advance.

     

    :)

  5. Hi folks,

    Wonder if someone can give me a hand :)

     

    If I had a variable like this:-

    $contents = "test keyword1 test test keyword1 test test test test test keyword2 test test test test test test keyword3 test test test test test test test keyword3 test test test test keyword1 test test test test test keyword3 test";

    and an array like this:-

    Array ([0] => test [1] => keyword1 [2] => keyword2 [3] => keyword3)

     

     

    How would I find out how many times each word in the array features in $contents ?

     

    The preferable return would be an array like this:-

    array('test' => 21, 'keyword1' => 3, 'keyword2' => 1, 'keyword3' => 3);

     

    Any help would be great :)

     

    Thanks in advance :D

  6. Hi folks,

     

    I'm trying to sensor some text variables (but in a specific way).

     

     

    Looks like this:-

     

    $text = "text text text BOB1 text text text";

    $replacetext = "*****";

     

    $var1 = array("BOB","JACK","BILLY","HARVEY","JOHN");

    $var2 = array("1","2","3","4","5");

     

     

    If $text has "BOB" anywhere in the variable then check if it has a number from $var2 joined to it. If it has the replace "BOB1" with $replacetext.

     

     

     

    Any ideas how to do this? Will love you forever if you can help.

     

    S.C>

  7. I've just recently upgraded to PHP Version 5.2.3 from 4.4.7 and noticed a problem with one of my GD images.

     

    duedate.gif

     

    It should use verdana.ttf for the text using the code below

    imagettftext($image, $fontSize, 0, $margin, 73, $black, $font, $tickerText);

     

    But for some reason the text is messed up... and ideas why?

     

     

    S.C>

     

  8. I'm trying to figure out how this __doPostBack function works in relation to the date form below.

     

    I'm trying to get a commission report for another site and want to find out what variables it posts and in what format.

     

    Can anyone help?

    Sample below.

     

    Oh and just a side note (that should be in the PHP forum but you may know) Is it possible to post variables using PHP CURL to an .aspx page?

     

    Regards,

    S.C>

     

     

    <form name="Form1" method="post" action="report.aspx" id="Form1">

    <input type="hidden" name="__EVENTTARGET" value="" />

    <input type="hidden" name="__EVENTARGUMENT" value="" />

     

     

    <script language="javascript" type="text/javascript">

    <!--

    function __doPostBack(eventTarget, eventArgument) {

    var theform;

    if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {

    theform = document.Form1;

    }

    else {

    theform = document.forms["Form1"];

    }

    theform.__EVENTTARGET.value = eventTarget.split("$").join(":");

    theform.__EVENTARGUMENT.value = eventArgument;

    theform.submit();

    }

    // -->

    </script>

     

     

    <TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">

    <TR>

    <TD><STRONG class="text"><span id="QuickDateSelector1_lblLangText820">Change date range</span>

    </STRONG>

    </TD>

    <TD></TD>

    </TR>

    <TR>

    <TD><STRONG class="text"><span id="QuickDateSelector1_lblLangText821">From</span></STRONG></TD>

    <TD><STRONG class="text"><span id="QuickDateSelector1_lblLangText822">To</span></STRONG></TD>

    </TR>

    <TR>

    <TD>

    <select name="QuickDateSelector1:ddlStartDay" id="QuickDateSelector1_ddlStartDay" class="smalltext" style="font-size:XX-Small;">

    <option value="1">1</option>

    <option value="2">2</option>

    <option value="3">3</option>

    <option value="4">4</option>

     

    </select>

    <select name="QuickDateSelector1:ddlStartMonth" id="QuickDateSelector1_ddlStartMonth" class="smalltext" style="font-size:XX-Small;">

    <option value="1">Jan</option>

    <option value="2">Feb</option>

    <option value="3">Mar</option>

    <option value="4">Apr</option>

     

    </select>

    <select name="QuickDateSelector1:ddlStartYear" id="QuickDateSelector1_ddlStartYear" class="smalltext" style="font-size:XX-Small;">

    <option value="2002">2002</option>

    <option value="2003">2003</option>

    <option value="2004">2004</option>

    <option value="2005">2005</option>

    <option value="2006">2006</option>

    <option value="2007">2007</option>

     

    </select></TD>

    <TD>

    <select name="QuickDateSelector1:ddlEndDay" id="QuickDateSelector1_ddlEndDay" class="smalltext" style="font-size:XX-Small;">

    <option value="1">1</option>

    <option value="2">2</option>

    <option value="3">3</option>

    <option value="4">4</option>

     

    </select>

    <select name="QuickDateSelector1:ddlEndMonth" id="QuickDateSelector1_ddlEndMonth" class="smalltext" style="font-size:XX-Small;">

    <option value="1">Jan</option>

    <option value="2">Feb</option>

    <option value="3">Mar</option>

    <option value="4">Apr</option>

     

    </select>

    <select name="QuickDateSelector1:ddlEndYear" id="QuickDateSelector1_ddlEndYear" class="smalltext" style="font-size:XX-Small;">

    <option value="2002">2002</option>

    <option value="2003">2003</option>

    <option value="2004">2004</option>

    <option value="2005">2005</option>

    <option value="2006">2006</option>

    <option value="2007">2007</option>

     

    </select></TD>

    </TR>

    </TABLE>

    <a id="QuickDateSelector1_lnkRunReport" class="boldblue" href="javascript:__doPostBack('QuickDateSelector1$lnkRunReport','')" style="width:67px;">Run Report</a><BR>

    <BR>

    <STRONG>

    <TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">

    <TR class="text">

    <TD style="WIDTH: 92px"><STRONG><span id="QuickDateSelector1_lblLangText823">Quick Links:</span></STRONG></TD>

    <TD colSpan="3">

    <a id="QuickDateSelector1_lnkLast7Days" class="text" href="javascript:__doPostBack('QuickDateSelector1$lnkLast7Days','')">Last 7 days</a>|

    <a id="QuickDateSelector1_lnkLast30Days" class="text" href="javascript:__doPostBack('QuickDateSelector1$lnkLast30Days','')">Month to date</a> |

    <a id="QuickDateSelector1_lnkLastCalendarMonth" class="text" href="javascript:__doPostBack('QuickDateSelector1$lnkLastCalendarMonth','')">Last calendar month</a></TD>

    </TR>

    </TABLE>

    </STRONG>

  9. I'm trying to get unix time based on data inputted into a drop down menu: example code below:-

     

     

    <select id="dateselector" value="day" class="datedropdown">
    <option onChange="updateDate();" value="01" name="inDay" >1</option>
    <option onChange="updateDate();" value="02" name="inDay" >2</option>
    <option onChange="updateDate();" value="03" name="inDay" >3</option>
    <option onChange="updateDate();" value="04" name="inDay" >4</option>
    ...
    <select id="dateselector" value="month" class="datedropdown">
    <option onChange="updateDate();" value="01" name="inMon" >January</option>
    <option onChange="updateDate();" value="02" name="inMon" >February</option>
    <option onChange="updateDate();" value="03" name="inMon" >March</option>
    ...
    <select id="dateselector" value="year" class="datedropdown">
    <option onChange="updateDate();" value="06" name="inYear" >2006</option>
    <option onChange="updateDate();" value="07" name="inYear" >2007</option>
    ...

     

     

    I have no idea how to get the updateDate() function to output unix time into 'var timestamp' as i have very little experience with .js

     

     

    I'm guessing it looks a little like:-

     

    function updateDate() {
    
        var timestamp = new Date(Date.UTC(document.getElementsByName("inYear").value,
              (stripLeadingZeroes(document.getElementsByName("inMon").value)-1),
               stripLeadingZeroes(document.getElementsByName("inDay").value),
               0, 0, 0));
               timestamp=timestamp.getTime()/1000.0;
    	   updateText();
    }

     

    (updateText(); then updates a text area)

     

    Any help to with the correct syntax would be great.

     

    Thanks in advance  :)

     

    S.C>

  10. Hi folks,

     

    I'm trying login into a website and store a webpage (that contains a sales report) in a variable.

     

    So far I can login using:-

    curl_setopt($ch, CURLOPT_URL, $login_url);

    curl_setopt ($ch, CURLOPT_POST, 1);

    curl_setopt ($ch, CURLOPT_POSTFIELDS, $login_post);

    curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookies!.txt');

    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

     

    But the reports page isn't the first page of the website. So I need to login, goto the reports page, submit the form details and capture the results in a variable.

     

    What I need is to login in using:-

    $login_url = Login Page

    $login_post = Contains login $_POST details

     

    This is the page with the reports FORM:-

    $reports_page = The URL with the form to select report

     

    post these details:-

    $reports_post = Contains $_POST details

     

    to this page

    $contents_url = The URL that the $_POST details are sent to

     

     

    ...and store the results in $page_contents

     

     

     

    Does that make any sense?

     

    I hope someone can help  ;D

     

     

     

    S.C>

     

     

  11. Cheers arianhojat,

    looks right but get an error.

    Fatal error: Cannot instantiate non-existent class: domdocument in /xml-import.php on line 3 ($xml = new DOMDocument;)

    I'm I right in guessing this is a problem with my PHP version?

    S.C>
  12. This is probably the wrong place to post this but I'm hoping someone who knows PHP here also knows ASP/IIS


    Is there a way of doing this:-
    [code]Dim xmlrequest
    Set xmlrequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
    xmlrequest.open "GET", strQuery, False
    xmlrequest.setRequestHeader "Content-type", "text/xml"
    xmlrequest.send

    xml.loadxml(xmlrequest.responseText)
    xsl.load(Server.MapPath(".") & "\results.xsl")[/code]


    ...in PHP?


    Regards,
    S.C>
  13. Can anyone work out what is wrong with this code?



    This is my my_query function:-
    [code]<?php

    $link = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die ("Could not connect to database. Try later<BR>");
    @mysql_select_db(DB_NAME, $link);

    function my_query($sql) {
      global $link;
      $result = @mysql_query($sql, $link);
      if ($result) return $result;
      if (DEBUG_MODE) { error_report(10); };

      return false;
    }
      ?>
    [/code]




    $_REQUEST['credit'] has a list for order numbers from a textarea:-

    [code]<?php

    $arr_orders = explode("\n",$_REQUEST['credit']);
    $where_clause = "WHERE trackingid IN ('".implode("','",$arr_orders)."')";

    $r = my_query("select user_id,site,offer,points,timedate,trackingid,status from offer_clicks " . "$where_clause");

      ?>
     
    <h1>Preview Accounts</h1><br> 

      <table border="1" cellspacing="0" cellpadding="2">
      <tr>
      <th bgcolor="#dddddd">Site</th> 
      <th bgcolor="#dddddd">User ID</th>
      <th bgcolor="#dddddd">Username</th> 
      <th bgcolor="#dddddd">Offer</th>
      <th bgcolor="#dddddd">Credit</th>
      <th bgcolor="#dddddd">Date / Time</th>
      <th bgcolor="#dddddd">Tracking ID</th> 
      <th bgcolor="#dddddd">Status</th>
      <th bgcolor="#dddddd">Credit</th>
      <th bgcolor="#dddddd">Pending</th>
      <th bgcolor="#dddddd">Reject</th>   
      </tr>
      <?php
        while (list($user_id,$site,$offer,$points,$timedate,$trackingid,$status) = mysql_fetch_array($r)) {
     
    $sql = my_query("select username from central_users where id='$user_id'");
    list($username) = mysql_fetch_row($sql);
    $sql = my_query("select site_name from site_options where site_prefix='$site'");
    list($site_name) = mysql_fetch_row($sql); 

      if ('0' == $status) {     
    $status = "Clicked"  ;
      }   
      if ('1' == $status) {     
    $status = "Credited"  ;
      } 
      if ('2' == $status) {     
    $status = "Pending"  ;
      }   
      if ('3' == $status) {     
    $status = "Rejected"  ;
      }     
    if ($points < 100) {
    $points = $points ." Credit";     
    }
    if ($points > 99) {
    $points = "Full Credit";
    }

      ?>
      <tr>
      <td width="75" align="center"><?php echo $site_name; ?></td>   
      <td width="75" align="center"><?php echo $user_id; ?></td>
      <td width="125" align="center"><?php echo $username; ?></td>
      <td width="125" align="center"><?php echo $offer; ?></td>
      <td width="100" align="center"><?php echo $points; ?></td> 
      <td width="110" align="center"><?php echo date("d-m-Y H:i",$timedate); ?></td>
      <td width="110" align="center"><?php echo $trackingid; ?></td> 
      <td width="75" align="center"><?php echo $status; ?></td>
      <td width="75" align="center"><INPUT TYPE=RADIO NAME="<?=$trackingid?>" VALUE="<?=$trackingid?>" CHECKED></td>
      <td width="75" align="center"><INPUT TYPE=RADIO NAME="<?=$trackingid?>" VALUE="<?=$trackingid?>"></td>
      <td width="75" align="center"><INPUT TYPE=RADIO NAME="<?=$trackingid?>" VALUE="<?=$trackingid?>"></td> 
      </tr>
      <?php
        }
      ?>
      </table> 
     
      <?php 

      return(0);
    }
      ?>[/code]


    Problem is it only displays the last order...
    any ideas?


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