piccadely Posted April 23, 2015 Share Posted April 23, 2015 I need a very simple script, if anyone can help me. User visits my site, he is shown a link. if that link is clicked more than 10 times, a new link is shown which comes from a flat file, file that contained the first link. User visits my site, fills in his link url and email address and his link is added last in the que of the above file. a way to see/edit/remove the links from the system which get a predefined number of clicks. User should not be able to submit more than one link. Let me know if anyone can help me on this. Quote Link to comment https://forums.phpfreaks.com/topic/295805-a-very-simple-script/ Share on other sites More sharing options...
ginerjm Posted April 23, 2015 Share Posted April 23, 2015 This is a helper forum, not a coding forum. If it's so simple (and it is) you s/b trying to write some simple code. As it stands, I don't follow what you are trying to say. You talk about seeing a link, clicking on that link, adding a link and saving a link and counting how many times one of those is clicked on. WTH are you doing? Quote Link to comment https://forums.phpfreaks.com/topic/295805-a-very-simple-script/#findComment-1509757 Share on other sites More sharing options...
Muddy_Funster Posted April 23, 2015 Share Posted April 23, 2015 your looking for the freelance board Quote Link to comment https://forums.phpfreaks.com/topic/295805-a-very-simple-script/#findComment-1509776 Share on other sites More sharing options...
piccadely Posted April 24, 2015 Author Share Posted April 24, 2015 (edited) your looking for the freelance board May be, I guess so. My knowledge of PHP is very limited, to modifying an existing code, not create one. I program in ASP, so I understand code, but not the whole PHP and I don't have enough time for the learning curve. If I were to do it in ASP, It would't have taken me more than half an hour for the whole project but PHP is kind of alien to me. Why it is simple? User visits my page (no coding required) User sees my link ("<a href="<? php the first URL in the flat file ?>"> Click here </a> <?php iteration to count the number of clicks on that link and change link to next one on the file, if the number of clicks reached 10, reset counter ?> next, Simple PHP form to capture the user details (this i guess, i can get from google as well) including link submitted by him and push that link to last of the que in the flat file accessed above. Next, <? php echo link and click stats ?> I understood what you said, that this is a help forum. I am just explaining what I need. May be someone can direct me to right resources. If there is already code, I can modify it to my needs. Edited April 24, 2015 by piccadely Quote Link to comment https://forums.phpfreaks.com/topic/295805-a-very-simple-script/#findComment-1509785 Share on other sites More sharing options...
Muddy_Funster Posted April 24, 2015 Share Posted April 24, 2015 I know nothing of asp, so I can sympathise with your position. However, you should know that PHP is a server side scripting language - it has no interaction with the user or the number of times they click. you would need a client side language for that, like javascript or actionscript. PHP can handle the file interaction (loading links from file / appending links to file) and can present an html form to the user - but that form will still need to be sent back to the server for PHP to interact with it again. so you're either talking about submitting the page and it's contents to the server each and every click to have PHP re-process it, or you need to include some of the client side stuff as well. I know on the surface it seems like it should be a 5 minute job, but assuming it still takes someone the same 30+minutes it takes you, for many of the people on this forum coding is their income, so if you are expecting them to take the time to produce code on your behalf, they will expect remunerated for the effort. Quote Link to comment https://forums.phpfreaks.com/topic/295805-a-very-simple-script/#findComment-1509817 Share on other sites More sharing options...
piccadely Posted April 25, 2015 Author Share Posted April 25, 2015 I know nothing of asp, so I can sympathise with your position. However, you should know that PHP is a server side scripting language - it has no interaction with the user or the number of times they click. you would need a client side language for that, like javascript or actionscript. PHP can handle the file interaction (loading links from file / appending links to file) and can present an html form to the user - but that form will still need to be sent back to the server for PHP to interact with it again. so you're either talking about submitting the page and it's contents to the server each and every click to have PHP re-process it, or you need to include some of the client side stuff as well. I know on the surface it seems like it should be a 5 minute job, but assuming it still takes someone the same 30+minutes it takes you, for many of the people on this forum coding is their income, so if you are expecting them to take the time to produce code on your behalf, they will expect remunerated for the effort. That is taking me somewhere.... Is it possible, if I ask specific questions, somebody can tell me the code. Like register a click in the database(flat file). Does this give any idea: <?php /******************************************************************************* * Title: PHP click counter (CCount) * Version: 2.0.3 from 25th January 2015 * Author: Klemen Stirn * Website: http://www.phpjunkyard.com ******************************************************************************** * COPYRIGHT NOTICE * Copyright 2004-2015 Klemen Stirn. All Rights Reserved. * This script may be used and modified free of charge by anyone * AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT. * By using this code you agree to indemnify Klemen Stirn from any * liability that might arise from it's use. * Selling the code for this program, in part or full, without prior * written consent is expressly forbidden. * Using this code, in part or full, to create derivate work, * new scripts or products is expressly forbidden. Obtain permission * before redistributing this software over the Internet or in * any other medium. In all cases copyright and header must remain intact. * This Copyright is in full effect in any country that has International * Trade Agreements with the United States of America or * with the European Union. * Removing any of the copyright notices without purchasing a license * is expressly forbidden. To remove copyright notice you must purchase * a license for this script. For more information on how to obtain * a license please visit the page below: * http://www.phpjunkyard.com/buy.php *******************************************************************************/ define('IN_SCRIPT',1); // Tell browsers not to cache the file output header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // Require the settings file require 'ccount_settings.php'; // Get the link ID; valid chars for the link ID are: 0-9 a-z A-Z - . and _ $id = isset($_REQUEST['id']) ? preg_replace('/[^0-9a-zA-Z_\-\.]/', '', $_REQUEST['id']) : die('Missing link ID'); // Open database file for reading and writing if ($fp = @fopen($ccount_settings['db_file'], 'r+')) { // Lock database file from other scripts $locked = flock($fp, LOCK_EX); // Lock successful? if ($locked) { // Read file $data = explode('//', fread($fp, filesize($ccount_settings['db_file'])), 2); // Convert contents into an array $ccount_database = isset($data[1]) ? unserialize($data[1]) : die('Invalid log file'); // Is this a valid link? if ( ! isset($ccount_database[$id]) ) { die('Link with this ID not found'); } // Increse count by 1 $ccount_database[$id]['C']++; // Is this a unique click or not? if ( ! isset($_COOKIE['ccount_unique_'.$id]) ) { $ccount_database[$id]['U']++; } // Update the database file rewind($fp); fwrite($fp, "<?php die();//" . serialize($ccount_database)); } else { // Lock not successful. Better to ignore than to damage the log file die('Error locking file, please try again later.'); } // Release file lock and close file handle flock($fp, LOCK_UN); fclose($fp); } // Print the cookie for counting unique clicks and P3P compact privacy policy header('P3P: CP="NOI NID"'); setcookie('ccount_unique_'.$id, 1, time() + 3600 * $ccount_settings['unique_hours']); // Redirect to the link URL header('Location: ' . str_replace('&', '&', $ccount_database[$id]['L']) ); die(); Can it be used to achieve what I am looking for. I will pay (in some way, if not in cash). I had this kind of script once which changed the URL of page being displayed after it was displayed a number of times. It was, I guess, a redirect script. If even that is possible, I could somehow make it work in my project. Quote Link to comment https://forums.phpfreaks.com/topic/295805-a-very-simple-script/#findComment-1509907 Share on other sites More sharing options...
piccadely Posted April 26, 2015 Author Share Posted April 26, 2015 As i had said earlier, if I knew php, it wouldn't take me much time. Here is a part of code thtat I required, I hope I will get others too. <?php $counter = file_get_contents("counter.txt"); $counter++; file_put_contents("counter.txt", $counter); echo $counter; ?> But I guess, this needs a little bit of more securing, if anybody can help on that...... Quote Link to comment https://forums.phpfreaks.com/topic/295805-a-very-simple-script/#findComment-1509963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.