Jump to content


Staff Alumni
  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About printf

  • Rank
    Prolific Member

Profile Information

  • Gender
    Not Telling
  1. printf

    regex to allow text and punctuation marks

    My regex makes no sense? I think it's the other way around. The OP asked for a regex that allows for punctuation marks at the end of a sentence, yours allows for repeated punctuation marks anywhere but the beginning of the sentence;;;;;;;:,, which makes no sense to me! If you want to strictly match a English literature sentence, then something like this will work. /^(?:\w+(\, |\; |\: | )){1,}(?:\w+(\.|\!|\?))$/i
  2. printf

    Forum Viewed

    didn't read, huh! Didn't read, new replies, new posts, new topics are one in the same to me. Since a users last visit, a user will encounter any of those references, if they are implemented. and a new topic, new post, new reply == a not read / unseen, new topic, new post, or new reply since their last visit. I don't believe I am missing the point, as giving a user the opportunity to know what is new / unseen / unread is a necessity but you have to in someway draw the line where that feature becomes impractical. I mean, it's not... see how smart I am, I know what you have viewed or not viewed because I am endlessly tracking you, it's simply giving them the ability to know what's has been going on since their last visit!
  3. printf

    Forum Viewed

    I didn't say I would do it one way or the other, I just used that as an example, and really how it is done doesn't matter, what matters is the result, which loads a database with junk. Do you really believe a user is interested in topics and posts that are years old... Hi printf, welcome back, did you know you forgot to read a post from 5 years ago... lol!
  4. printf

    Forum Viewed

    Having features in your software that don't reflect the true facts while using CPU clocks to support that feature is stupid. Let me give you a better example. Most people I know use Google Maps to get directions to go everywhere. And like you stated, 'features like that are pretty cool features', they give you that wow factor! But would you give your '12 year old child' a phone and tell them to use Google Maps to navigate wherever they are wanting to go, I WOULDN'T, why, because your child just might die believing Google Maps is a safe mapping program when it's not, and no that isn't entirely Google's fault, but it is partly their fault, because they don't personal audit every bit of their mapping data. Now, you might say, what does that have to do with what we are talking about, not a lot, but my point is simple, you shouldn't put things out there that just guess at stuff just because you think it's cool. And just so you know, people have gotten lost, even died trusting Google maps. Anyway, back to what I was really wanting to say... My problem isn't so much with the silly features some developers implement, but I do have a problem with how they are implemented. Things like, who's online, total topics, total posts, etc; should not be handled in your script, as they are things that change when another action takes place. Say you add a new topic, that creates a new topic and a new post, so you have to update you totals, (topics & posts) so you run a query or two to do that, instead of using the database to do it for you, trigger(do this), which makes no sense to me. Now compound that simple developers mistake X 10, and you will end up doing (10,000) unneeded things on a forum that generates (1000) new topics / posts a day. That to me tells me whoever developed that software is not a developer, to me they are just a script kiddie doing things in most illogical way...
  5. printf

    Forum Viewed

    Wow, tables would be filled with tons of junk, not very practical if you ask me. it sort of like the "glass half filled theory", if you start with "posts / topics not viewed", it's like the glass is half full, but when the user starts reading a lot of posts / topics, the database will soon become bloated and the glass half full will become half empty, (just to tell them what topics or post they haven't viewed), like I said, it's not very practical. I always recommend the minimum, highlight posts and topics that are new since they last visited. You know thinking about things like this makes me kind of laugh at developers who waste run-time resources on such silliness when their code base could use a lot of improvement. Its like the other crazy stuff most forum software have, one example... "You have spent 43 days, 7 hours, 14 minutes, and 7 seconds on our forum", to me that is simply stupid, because you cannot maintain 'state', so their implementing a 'where just guessing' is stupid, (period) And yes, I know I am very opinionated, but having spent countless hours modifying forum software for my many clients, I do know what I am talking about!
  6. Okay, based on what you are wanting to do, I will tell you how to do those things... you said.... First I need to know how the data can be sorted by published year... I said.... To do that you will need to go through the whole file and place the valid data into an array, then sort that array on the column that you want to sort on you said... Then if there is any error in my text file like any field missing, say birth year is missing, skip that whole line from my output table and append that line into another text file. I said.... to do that, while you are going through your books database, add a if() condition that test for those missing values. In this case you know your database must contain (5) columns of data, so if(sizeof($line)) , which represents a row of data doesn't equal (5), you would add that line to a 'missing' data file you said... Third filter, is based on published year, if published year is grater than birth year then its an error, again that should skip the line from my output table and append this into another text file. I said.... to do that, while you are going through your books database, add a if() condition that test for those invalid values. So if the publishing year is greater than the birth year. append that line to a 'invalid' data file... Now my simple example... /* books database file 'books.txt' */ title1 John Doe 1960 1935 title2 Jane Doe 1970 1935 title3 John Doe 1935 title4 Jason Doe 1971 1960 title5 Gee Swan 1960 1984 title6 Jane Doe 1935 1970 2015-09-01 Dave Hertner 2000 1984 2001-02-28 Ron Swan 1999 2011-05-20 Mark Ramsay 2001 1980 Now a quick script that you can study... (untested but it should work) <?php // function put in file function putFile ( $file, $data, $new = 'w' ) { $io = fopen ( $file, $new ); fputs ( $io, implode ( ' ', $data ) . "\r\n" ); fclose ( $io ); } // sorting functions // sort newest to oldest function sortA ( $a, $b ) { return ( $a['pyear'] == $b['pyear'] ? 0 : ( $a['pyear'] > $b['pyear'] ? -1 : 1 ) ); } // sort oldest to newest function sortD ( $a, $b ) { return ( $a['pyear'] == $b['pyear'] ? 0 : ( $a['pyear'] < $b['pyear'] ? -1 : 1 ) ); } // books database $db = 'books.txt'; // missing data file $mf = 'missing.txt'; // invalid file ( publising year > birth year ); $if = 'invalid.txt'; // valid row size $vs = 5; // column names $cn = array ( 'title', 'fname', 'lname', 'pyear', 'byear' ); // output container $oc = array (); // db handle $io = fopen ( $db, 'r' ); // read the books db while ( ! feof ( $io ) ) { $line = explode ( ' ', trim ( fgets ( $io, 1048 ) ) ); if ( sizeof ( $line ) != 5 ) { putFile ( $mf, $line, 'a' ); continue; } elseif ( ( int ) $line[3] > ( int ) $line[4] ) { putFile ( $if, $line, 'a' ); continue; } else { $oc[] = array_combine ( $cn, $line ); } } fclose ( $io ); // sort the books array, sort oldest to newest uasort ( $oc, 'sortD' ); // just show the result print_r ( $oc ); ?>
  7. printf

    regex to allow text and punctuation marks

    Something like... "/^[a-z\s]{4,30}+([\.!,;:-?]{1}+)?$/i",
  8. printf

    PHP Select

    could you please post a link to a php info file on the server that is running this code... // link to... <?php phpinfo(); ?>
  9. printf

    Error on Object Variable for paging

    change your code to this.... <?php global $PREFS, $TEMPLATE, $SESSION; include_once SYS_PATH . "includes/ext/ext.anchor.php"; include_once SYS_PATH . "includes/ext/core/ext.lang.php"; include_once SYS_PATH . "includes/ext/core/ext.dropdownlist.php"; include_once SYS_PATH . "includes/ext/core/ext.trim.php"; include_once SYS_PATH . "includes/ext/core/ext.ifelse.php"; ?><?php $_temp_inc = $TEMPLATE->output('header.tpl',0); include($_temp_inc); ?> <div class="header_wrap"> <div class="options_wrap"> <div class="title"> <ul><li><?php echo vldext_lang("search","app_results"); ?></li></ul> </div> <div class="clear"></div> </div> </div> <?php if ( ( int ) $_obj['page_links'] == 1 ) { ?> <p>Welcome to our website</p> <?php } ?> <?php $_temp_inc = $TEMPLATE->output('message.tpl',0); include($_temp_inc); ?> <?php if ( ( int ) $_obj['hide_content'] != 1) { ?> <div class="outter page_search_results"> <div class="typemembers"> <?php if ( @$PREFS->conf['enable_saved_searches'] && @$SESSION->conf['can_save_searches'] ) { ?> <div class="dataitem single" id="div_save_search" style="display: none"> <div class="form"> <div class="entry" id="save_search_response"> <form name="form_save_search" id="form_save_search" action="" onsubmit="save_search();return false;" method="post"> <div class="fieldset"> <dl class="fieldset fieldgrid"> <dt><label for="field_search_save"><?php echo vldext_lang("search","save_search"); ?></label></dt> <dd><input name="search_save" type="text" class="text" id="field_search_save" style="width: 200px" value="" maxlength="128" /></dd> <dd class="submit report"> <input id="save_search_submit" class="submit" name="submit" value="<?php echo vldext_lang("search","submit"); ?>" type="submit" /> <div class="progress" id="save_search_progress"></div> <div class="clear"></div> </dd> </dl> <div class="clear"></div> </div> <input type="hidden" id="field_hash" name="hash" value="<?php echo isset($_obj['search_hash']) ? $_obj['search_hash'] : "{search_hash}"; ?>" /> </form> </div> </div> </div> <?php } ?> <div class="dataitem single" id="div_reorder" style="display: none"> <div class="form"> <form name="form_reorder" action="<?php echo isset($_obj['virtual_path']) ? $_obj['virtual_path'] : "{virtual_path}"; ?><?php echo isset($_obj['search_link']) ? $_obj['search_link'] : "{search_link}"; ?>" method="post"> <div class="fieldset"> <dl class="fieldset fieldgrid"> <dt><label for="field_orderby"><?php echo vldext_lang("search","order_by"); ?></label></dt> <dd><select class="select" name="orderby" id="field_orderby"><?php echo vldext_dropdownlist($_obj['orderby_box'],$_obj['search_orderby']); ?></select></dd> <dt><label for="field_direction"><?php echo vldext_lang("search","direction"); ?></label></dt> <dd><select class="select" name="direction" id="field_direction"><?php echo vldext_dropdownlist($_obj['direction_box'],$_obj['search_direction']); ?></select></dd> <dt><label for="field_display_type"><?php echo vldext_lang("search","display_type"); ?></label></dt> <dd><select class="select" name="display_type" id="field_display_type"><?php echo vldext_dropdownlist($_obj['displaytype_box'],$_obj['displaytype']); ?></select></dd> <dd class="submit"><input class="submit" name="submit" value="<?php echo vldext_lang("search","submit"); ?>" type="submit" /></dd> </dl> <div class="clear"></div> </div> </form> </div> </div> <?php if ( ( int ) $_obj['displaytype'] == 1) { ?> <div class="dataitem single gallerybox"> <?php if (!empty($_obj['search_profiles'])){ if (!is_array($_obj['search_profiles'])) $_obj['search_profiles']=array(array('search_profiles'=>$_obj['search_profiles'])); $_tmp_arr_keys=array_keys($_obj['search_profiles']); if ($_tmp_arr_keys[0]!='0') $_obj['search_profiles']=array(0=>$_obj['search_profiles']); $_stack[$_stack_cnt++]=$_obj; $_cnt['search_profiles']=count($_obj['search_profiles']); foreach ($_obj['search_profiles'] as $rowcnt=>$search_profiles) { $search_profiles['rowcnt']=$rowcnt; $search_profiles['rowpos']=$rowcnt+1; $search_profiles['rownum']=$rowcnt%2+1; $search_profiles['rowtotal']=$_cnt['search_profiles']; $search_profiles['rowfirst']=$rowcnt==0?1:0; $search_profiles['rowlast']=($rowcnt+1)==$_cnt['search_profiles']?1:0; $_obj=&$search_profiles; ?> <div class="image"> <?php $_temp_inc = $TEMPLATE->output('member_sections_picture.tpl',0); include($_temp_inc); ?> <ul><li><a href="<?php echo isset($_stack[0]['virtual_path']) ? $_stack[0]['virtual_path'] : "{virtual_path}"; ?><?php echo isset($_obj['member_profile_link']) ? $_obj['member_profile_link'] : "{member_profile_link}"; ?>"><?php echo vldext_trim($_obj['member_username'], ; ?>, <?php echo isset($_obj['profile_field_age_value_years']) ? $_obj['profile_field_age_value_years'] : "{profile_field_age_value_years}"; ?></a></li></ul> </div> <?php } $_obj=$_stack[--$_stack_cnt];} ?> <div class="clear"></div> </div> <div class="clear"></div> <?php } else { ?> <?php if (!empty($_obj['search_profiles'])){ if (!is_array($_obj['search_profiles'])) $_obj['search_profiles']=array(array('search_profiles'=>$_obj['search_profiles'])); $_tmp_arr_keys=array_keys($_obj['search_profiles']); if ($_tmp_arr_keys[0]!='0') $_obj['search_profiles']=array(0=>$_obj['search_profiles']); $_stack[$_stack_cnt++]=$_obj; $_cnt['search_profiles']=count($_obj['search_profiles']); foreach ($_obj['search_profiles'] as $rowcnt=>$search_profiles) { $search_profiles['rowcnt']=$rowcnt; $search_profiles['rowpos']=$rowcnt+1; $search_profiles['rownum']=$rowcnt%2+1; $search_profiles['rowtotal']=$_cnt['search_profiles']; $search_profiles['rowfirst']=$rowcnt==0?1:0; $search_profiles['rowlast']=($rowcnt+1)==$_cnt['search_profiles']?1:0; $_obj=&$search_profiles; ?> <div class="dataitem <?php echo vldext_ifelse($_obj['rownum'],"1","odd","even"); ?> <?php echo vldext_ifelse($_obj['rowlast'],"1","dataitemlast",""); ?>"> <table class="plain"> <tr> <td> <div class="image"> <?php $_temp_inc = $TEMPLATE->output('member_sections_picture.tpl',0); include($_temp_inc); ?> </div> </td> <td class="data"> <div class="datainfo"> <?php $_temp_inc = $TEMPLATE->output('member_sections_name.tpl',0); include($_temp_inc); ?> <dl class="datainfo"> <?php $_temp_inc = $TEMPLATE->output('member_sections_card.tpl',0); include($_temp_inc); ?> </dl> </div> </td> <td> <div class="actions"> <ul class="actions"> <?php $_temp_inc = $TEMPLATE->output('member_sections_quick_actions.tpl',0); include($_temp_inc); ?> </ul> </div> </td> </tr> <tr> <td colspan="3"> <div> <?php echo vldext_trim($_obj['profile_field_inmyownwords_value'],300); ?></div> </td> </tr> </table> </div> <?php } $_obj=$_stack[--$_stack_cnt];} ?> <?php } ?> </div> <div class="clear"></div> </div> <?php if ( ( int ) $_obj['total_pages'] > 1) { ?> <div class="footer_wrap"> <div class="footer"> <p><?php echo vldext_lang("search","page_numbers"); ?></p> <?php echo isset($_obj['page_links']) ? $_obj['page_links'] : "{page_links}"; ?> <div class="clear"></div> </div> </div> <div class="clear"></div> <?php } ?> <?php } ?> <?php $_temp_inc = $TEMPLATE->output('footer.tpl',0); include($_temp_inc); ?>
  10. printf

    OOP PHP How to Find Total Quantity

    your cart should have it's on $key['quantity] that way when a item is added or removed it's as simple as $key['quantity] += 1; || -= 1; That will save you from having to loop your cart every time a item is added or removed just to get the total items in your cart. Think of it this way... cart items are unique so they need an array() of item(s), but things like total items, total price, etc... are not unique, so they only need a single $key => $value;
  11. printf

    need to display data form

    Use sessions, or just do a redirect with the date value in your url.
  12. printf

    foreachs in to file (.txt)

    before your foreach() $s2 = ''; inside your foreach(), change to... ( missing concentration operator ('.') ) after $s2 .= $s2 .= '<li>' . '<span>' . date('j.n.Y',$ti['createdAt']) . '</span>' . ' - ' . $ti['text'] . '</li>';
  13. printf

    add Google recaptcha to contact form

    Could you try this code... if I recall, curl 7.20.*, and 7.21.* has problems with CURLOPT_POST | CURLOPT_POSTFIELDS if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) { if( isset ( $_POST['g-recaptcha-response'] ) && ! empty ( $_POST['g-recaptcha-response'] ) ) { $key = 'my key'; $rip = $_SERVER['REMOTE_ADDR']; $captchaurl = 'https://www.google.com/recaptcha/api/siteverify?'; $captchaurl .= 'secret=' . $key . '&'; $captchaurl .= 'response=' . $_POST['g-recaptcha-response'] . '&'; $captchaurl .= 'ip=' . $rip; $curl_init = curl_init (); curl_setopt ( $curl_init, CURLOPT_URL, $captchaurl ); curl_setopt ( $curl_init, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $curl_init, CURLOPT_TIMEOUT, 5 ); curl_setopt ( $curl_init, CURLOPT_USERAGENT, 'PHP/reCAPTCHA' ); curl_setopt ( $curl_init, CURLOPT_SSL_VERIFYPEER, FALSE ); $response = curl_exec ( $curl_init ); if ( $response == FALSE ) { echo '<p>Curl Error: ' . curl_error ( $curl_init ); } else { $result = json_decode ( $response, TRUE ); echo 'Recaptha Result: '; var_dump ( $result['success'] ); } curl_close ( $curl_init ); } }
  14. printf

    Help in Opencart sms notification to user

    create a new method with your sms code in the class "ControllerAccountRegister extends Controller", then call that method right before... // your sms method call here... $this->sendSMS(); $this->response->redirect($this->url->link('account/success')); but I myself would turn it into an extension, that way I could control it from the admin panel... but how to do that goes beyond the scope of a scripting help forum.
  15. printf

    Styling Comment Section from Database

    This looks like a PHP question, not a SQL question! Anyway, move the <table> out of the loop, and then just style your <tr> tag with a border-top or border-bottom. <td> <table class='commenttable'> <?php include '../Scripts/connection.php'; $sql = "SELECT id, name, email, subject, comment FROM comment"; $result = $connect->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo " <tr style=\"border-bottom: 1px solid #000;\"> <td class='id'> <u>Loyal Client ". $row["id"] . "</u>: </td> <td class='subject'> " . $row["subject"]. " </td> </tr> <tr> <td></td> <td class='comment' colspan='2'> " . $row["comment"]. " </td> </tr> "; } } else { echo " <tr> <td> No Comments </td> <tr> "; } ?> </table> </td>

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.