PHP - Crot Anti-plagiarism Resubmit And Check If Date Has Modified.
Hello guys, i have a problem that i am trying to solve myself for the entire past week. I am not a php programmer and i wish you can help me.
There is a russian project called Crot Anti-Plagiarism, it is a open source moodle plugin. I started to use it and it is a really nice feature. The problem is that there are quite few people that are developing it and new features are coming once a year... I see a big "hole" in this project (at least for me) : The plugin checks for plagiarism in the file that you submit only once, if a student resubmits the file it doesn't see that and you need to start the plugin's test again for all the files which is time consuming if you have a lot of submitted files to check. I would like to add a function that will check if a file changed his modified date , if yes - mark for checking, if no - skip the checking. I already added a similar function that checks if the name has changed, but it seems harder to check it by uploaded time(modified time). Things i have already done: I added a new column "assignment_submissions_timemodified" in database. I added a new function that records the "time modified" of the file in the database. But i can't add and i cannot make the comparison between the date of the first time the file submitted versus the date of the second time the same file was resubmitted. Alright no more bullsh**t here is the code: (there are 3 comments that shows what i've changed, starting with //my job...) Thanks a lot! Code: [Select] $apath= $CFG->dataroot."/$assignment->course/moddata/assignment/$asubmission->assignment/$asubmission->userid"; $timemodified= filemtime($apath); //my job... it checks the file's modified time. $files = scandir($apath, 1); if (! $unprocessedsubm = get_record("crot_submissions", "submissionid", $asubmission->id, "crot_submission_file_name", $files[0], "assignment_submissions_timemodified", $timemodified)) //my job...now i guess here is the problem ( "assignment_submissions_timemodified", $timemodified) { echo "$timemodified"; echo "$unprocessedsubm"; print_r($unprocessedsubm); echo "\nsubmission $asubmission->id was not processed yet. start processing now ... \n" ; $atime = microtime(); $atime = explode(" ",$atime); $atime = $atime[1] + $atime[0]; $astarttime = $atime; if(!count($files))break; //TODO we should verify if filename changed //TODO add loop on the documents folder as well as loop for unzipping $apath = $apath."/$files[0]"; // call tokenizer to get plain text and store it in crot_submissions $atext = tokenizer ($apath); // update the crot_submissions table // delete if exists delete_records("crot_submissions", "submissionid", $asubmission->id); // insert the new record $record->submissionid=$asubmission->id; $record->updated = time(); $record->crot_submission_file_name = $files[0]; $record->assignment_submissions_timemodified = $timemodified; //this is my job.... it is recording the date as it has to. $submid = insert_record("crot_submissions", $record); // insert into documents $docrecord->crot_submission_id = $submid; Also i have attached the whole file crot_crone.php. Similar TutorialsHi, I'm currently using a voting script, but have a problem with people voting more then once, and want to add a way to keep the voting unique and 1 per person via IP check can anybody assist me how to implement it in the following script please?
<?php // the questions and the answers $pool_question="Do you think I should keep Galaxy Universe open?"; $pool_option[1]="Yes"; $pool_option[2]="No"; // If counter files are not available,they will be created // You may remove next lines after the first use of the script if (!file_exists("pool_5483543_1.txt")){ // next two lines will not work if writing permissions are not available // you may create the files bellow manualy with "0" as their unique content file_put_contents ("pool_5483543_1.txt",0); file_put_contents ("pool_5483543_2.txt",0); } // retrieve data saved in files $pool_responses[1]=file_get_contents("pool_5483543_1.txt"); $pool_responses[2]=file_get_contents("pool_5483543_2.txt"); // if user votes, increase corresponding value if ($_POST["5483543"] and $_POST["5483543b"]==""){ if ($_POST["5483543"]==1) {$pool_responses[1]++;file_put_contents("pool_5483543_1.txt",$pool_responses[1]);} if ($_POST["5483543"]==2) {$pool_responses[2]++;file_put_contents("pool_5483543_2.txt",$pool_responses[2]);} } // get percentajes for each answer in the pool // get total number of answers $total_responses=$pool_responses[1]+$pool_responses[2]; if ($total_responses==0){$total_responses=1;} // to avoid errors at start // compute percentajes (with one decimal number) $pool_percentaje[1] = round((100*$pool_responses[1])/$total_responses,1); $pool_percentaje[2] = round((100*$pool_responses[2])/$total_responses,1); // print the form, which includes de answers and the percentajes print "<center>\n"; print "<form method=post action=".$_SERVER["PHP_SELF"].">\n"; print "<b>".$pool_question."</b>\n"; print "<table cellpadding=4>\n<br>"; // answer 1 print "<tr>\n"; print "<td><input type=radio name=5483543 value=1> ".$pool_option[1]."</td>\n"; print "<td bgcolor=DDDDFF>" .$pool_responses[1]." (".$pool_percentaje[1]."%)</td>\n"; print "</tr>\n"; // answer 2 print "<tr>\n"; print "<td><input type=radio name=5483543 value=2> ".$pool_option[2]."</td>\n"; print "<td bgcolor=DDDDFF>" .$pool_responses[2]." (".$pool_percentaje[2]."%)</td>\n"; print "</tr>\n"; print "</table>\n"; // a simple control to avoid one user to vote several times if ($_POST["5483543"]){ print "<input type=hidden name=5483543b value=1>\n"; } print "<input TYPE=submit value=Add my answer>\n"; print "</form>\n"; print "</center>\n"; ?>The reason why I ask for IP check is I wan't to use $_SERVER["HTTP_X_MXIT_USERID_R"];in the place of the Ip since it give a unique name via the platform I want to implement it. Edited by cobusbo, 14 January 2015 - 01:49 PM. I have a small script on the bottom of all my pages on my site which list the date and time the page was modified. I want to make the script an include and just put that on the page, but as it is now scripted that won't work since you have to change the page name for every page. Is there a way to change this so it can be an include? $last_modified = filemtime("pagename.php"); print("Last Modified "); print(date("m/j/y h:i", $last_modified));?> Login.php Code: [Select] <?php session_start(); mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("cute") or die(mysql_error()); $username = $_POST['username']; $password = $_POST['pass']; if (isset($_POST["submit"])) { $log = "SELECT * FROM regis WHERE username = '$username'"; $login = mysql_query($log); $row = mysql_fetch_array($login); $number = mysql_num_rows($login); if ($number == 0) { print "That user does not exist in our database. <a href=registration.php><input type='button' value='Register'></a>"; } if ($number > 0) { if ($password == $row['password']) { $_SESSION['username'] = $row['username']; $_SESSION['userlevel'] = $row['userlevel']; $_SESSION['is_logged_in'] == 1; if($_SESSION['userlevel']==1) { $_SESSION['is_logged_in'] == 1; echo "<meta http-equiv='refresh' content='0; url=form2.php'>" ; } else if($_SESSION['userlevel']==0) { echo "<meta http-equiv='refresh' content='0; url=registration.php'>"; } } } } else { ?> <html> <head> <script type="text/javascript"> function a() { var x = document.login.username.value; var y = document.login.pass.value; if(x==""&& y=="") { alert("Please insert all message!"); return false; } if(x=="") { alert("Please insert an username!"); return false; } if(y=="") { alert("Please insert an password!"); return false; } } </script> </head> <body> <table border="0"> <form name="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return a()"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td> <td><input type="text" name="username" maxlength="40"></td></tr> <tr><td>Password:</td> <td><input type="password" name="pass" maxlength="50"></td></tr> <tr><td><input type="submit" name="submit" value="Register"></a></td> <td><input type="submit" name="submit" value="Login"></td></tr> </form> </body> <?php } ?> </html> after im redo my code and after im login there nothign happen but only blank page im wondering why Hi, I have database stored a field of date. I want to check if the date in the DB field is the same as the current date, how to do it? Code: $oracle = mysqli_real_escape_string($con, $_POST['oracle']); $query = mysqli_query($con, "SELECT indate FROM staff WHERE OracleID ='$oracle'"); $row = mysqli_fetch_array($query); $num_row = mysqli_num_rows($query); if ($num_row > 0) { $curdate = date(); if ($row['indate'] !== $curdate) { $query1=mysqli_query($con, "update staff set ClockedIn = 0, ClockedOut = 0 where OracleID='$session_id'")or die('Error In Session'); header('location:home.php'); } }
Hi Guys, Need some help I have two dates: Now= 2011-02-08 Expires= 2011-06-15 How can I check if we are getting close to the expire date. For example. Lets say we were 5 days away from 2011-06-15 ( todays date was 2011-06-10 ) for example.. How can i tell this? / return 1 Ie: if date is 5 days or less away do ( this ) Its s essentially so i can email people when something is due to expire. Many thanks L I want to see if a date is more than 10 days overdue. if ($row['duedate'] < "todays date plus 10 days"){ How do I do that? I put in quote sup there in "english" what I want... Any programmer here who can help me to create plagiarism checker? please i need a reply. thanks in advance. godbless
Any body here who can help me to make a plagiarism checker in php? that can accurately get the site of the content that is copied from internet. thanks in advance. godbless.
Currently I have an Input field for a "Written On Date". What is the best way to make sure a valid date is entered? Should I use Regular Expressions? Some PHP Date-Checking Function? Or switch to Drop-Down Lists to better control the selectable values? (Which won't catch things like June 31?!) Debbie What is the best way to check for a Date in a Form? I see there is a CheckDate() function, but how does that know what format the Date is in? Should I use a Regular Expression? My Form Field is just a Text Box... Thanks, Debbie Hi I made a simple chat script with pagination in MySQL (yes I know I should change to MySQLi) but just bare with me please My script is working fine when I post messages, but I have a problem.. Each time I refresh my page my previous message gets reposted again. Is there maybe a way I can fix this problem?
<html> <?php define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); // database connection info $conn = mysql_connect('****','******','*****') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('*****'',$conn) or trigger_error("SQL", E_USER_ERROR); // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM StringyChat"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 20; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // INSERT INTO DATABASE $ip = $_SERVER["REMOTE_ADDR"]; $name = $_SERVER["HTTP_X_MXIT_USERID_R"]; $msg = $_POST['message']; $time = date("U"); $mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"]; if(!isset($mxitid, $name )) { $mxitid = "DEFAULT"; $name = "SYSOP"; } $sqli = "INSERT INTO StringyChat (StringyChat_ip, StringyChat_name, StringyChat_message, StringyChat_time, mxit_id) VALUES ('$ip', '$name', '$msg', '$time', '$mxitid')"; $result = mysql_query($sqli, $conn) or trigger_error("SQL", E_USER_ERROR); // get the info from the db $sql = "SELECT StringyChat_time, StringyChat_name, StringyChat_message FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); function filterBadWords($str) { $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); $replacements = ":-x"; while($row = mysql_fetch_assoc($result1)) { $str = eregi_replace($row['word'], str_repeat(':-x', strlen($row['word'])), $str); } return $str; } // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) //while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) { // echo data //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />'; } // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?><br> // FORM <body> <form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>"> <br> <input type="hidden" name="name" class="StringyChatFrm" value="<?php $name ?>" size="20" > <br> <i>Type your Message here...</i>:<br> <textarea name="message" class="StringyChatFrm" cols="20" rows="4"></textarea> <br> <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message"> </form> </body> </html> check date is in format of Y-m-d I am trying to check if a credit card has expired. My criterion is whether or not the date submitted is prior to this month if the year matches 2011. Code: [Select] // Check for Expired Card. if (($expYear = date('Y')) && ($expMonth < date('M'))){ $errors['expDate'] = 'Expiration Date cannot be in the past.'; } Why is this not working? I chose March 2011 and it fails. In fact, it fails for any date?! Debbie Hi all, How can I check in PHP if this date has already passed in the following format: 2012-12-12 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=313543.0 I have two text fields in a form. Both accepts dates. I'd like to check whether the second date provided is exactly one year in the future from the first provided date.
I can easily do this in PHP but since I need to do the check once the user leaves the second field, I have to resort to JavaScript, using onblur or something.
There are two issues I have.
1. Make sure that the strings provided are indeed dates (I would use strtodate() in PHP for this)
2. Regardless of month provided, making sure that the second date is exactly a year in the future of the already provided year
I've only captured the values and passed them to Date(). However, it can only handle european style, and if I enter 1981-06-16, the value returned is Jun 15 1981 17:00:00 which is obviously wrong.
Here is the simple broken code I have
var text1 = document.getElementById("text1"); var start_date = new Date(text1.value); var text2 = document.getElementById("text2"); var end_date = new Date(text2.value); alert(start_date);I need some guidance. Using MVC, the controller does some logic, gets data from the model, and the view presents the content.
Where should the reverse be performed?
For instance, I have an edit page which is pre-populated with values from the model, and the view changes 1000 to $1,000, 0.4 to 40%, and 2014-10-09 09:31:41 to 10/09/2014 09:31:41 AM.
Now I need to save the values, and must convert them back to their original format before doing so. Should this functionality be performed in the controller, model, or view?
Thanks
i am using a Anti MySQL Injection my friend made for me config.php //Anti MySQL Injection function anti_injection($sql) { // removes words that contain sql syntax $sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$sql); $sql = trim($sql); // strip whitespace $sql = strip_tags($sql); // strip HTML and PHP tags $sql = addslashes($sql); // quote string with slashes return $sql; } <?php include "./config.php"; $title = $_POST[title]; $type = $_POST[type]; $episode = $_POST[episode]; $year = $_POST[year]; $genre = $_POST[genre]; $status = $_POST[status]; $summary = $_POST[summary]; $pictures = $_POST[pictures]; $title = anti_injection($title); $type = anti_injection($type); $episode = anti_injection($episode); $year = anti_injection($year); $genre = anti_injection($genre); $status = anti_injection($status); $summary = anti_injection($summary); $pictures = anti_injection($pictures); ?> When i enter the data from the text box and click submit it still puts the data in to the date base but it shows ]Notice: Use of undefined constant title - assumed 'title' in C:\wamp\www\studying\take 2\addin11.php on line 41 Notice: Use of undefined constant type - assumed 'type' in C:\wamp\www\studying\take 2\addin11.php on line 42 Notice: Use of undefined constant episode - assumed 'episode' in C:\wamp\www\studying\take 2\addin11.php on line 43 Notice: Use of undefined constant year - assumed 'year' in C:\wamp\www\studying\take 2\addin11.php on line 44 Notice: Use of undefined constant genre - assumed 'genre' in C:\wamp\www\studying\take 2\addin11.php on line 45 Notice: Use of undefined constant status - assumed 'status' in C:\wamp\www\studying\take 2\addin11.php on line 46 Notice: Use of undefined constant summary - assumed 'summary' in C:\wamp\www\studying\take 2\addin11.php on line 47 Notice: Use of undefined constant pictures - assumed 'pictures' in C:\wamp\www\studying\take 2\addin11.php on line 48 Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\studying\take 2\config.php on line 30 Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\studying\take 2\config.php on line 30 Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\studying\take 2\config.php on line 30 Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\studying\take 2\config.php on line 30 Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\studying\take 2\config.php on line 30 Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\studying\take 2\config.php on line 30 Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\studying\take 2\config.php on line 30 Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\studying\take 2\config.php on line 30 And thanks to the Anti MySQL Injection my Primary key in my database dont work :s can you help? thank you This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=355195.0
Below is my contact from - and I have set anti spam question as I don't like captcha. How to I code the post/human bit so it is case insensitive?
<div class="one-half-column-right" id="contactform"> <form method="post" action="index.php#contactform"> <label>Name*</label> <div class="clear"></div> <input name="name" placeholder="Type Here"> <label>Email*</label> <div class="clear"></div> <input name="email" type="email" placeholder="Type Here"> <label>Message</label> <textarea name="message" placeholder="Type Here"></textarea> <label>*If today is Tuesday, what is tomorrow? <br> [lowercase answer please]<br> (Anti-spam)</label> <input name="human" placeholder="Type Here"> <input id="submit" name="submit" type="submit" value="Submit"> </form> <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Website Form'; $to = ‘name@name.com’; $subject = 'website form enquiry'; $human = $_POST['human']; $headers .= 'From: '.$from."\r\n". 'Reply-To: '.$from."\r\n" . 'X-Mailer: PHP/' . phpversion(); $body = "From: $name\n E-Mail: $email\n Message:\n $message"; if ($_POST['submit'] && $human == ‘wednesday’) { if (mail ($to, $subject, $body, $from)) { echo '<p style="font-family: Montserrat, Helvetica, Arial, sans-serif; font-weight: 600; text-align:center; font-size: 16px; color: #000; text-transform: uppercase; background-color: #FFD700"> Request has been sent. We will get back to within 48 hours!<br></p>'; } else { echo '<p style="font-family: Montserrat, Helvetica, Arial, sans-serif; font-weight: 600; text-align:center; font-size: 16px; color: #000; text-transform: uppercase; background-color: #FFD700"> Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '') { echo '<p style="font-family: Montserrat, Helvetica, Arial, sans-serif; font-weight: 600; text-align:center; font-size: 16px; color: #000; text-transform: uppercase; background-color: #FFD700"> You answered the anti-spam question incorrectly!</p>'; } ?> <!--// form //-->
|