Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach (new DirectoryIterator('.') as $item) {
- echo $item, PHP_EOL;
- }
- <?php
- $orderId = $_GET['orderid'];
- $dir = new DirectoryIterator('uploads');
- $fileMatches = array();
- foreach ($dir as $fileinfo) {
- $filenameId= substr($fileinfo->getFilename(), 0, 9);
- if($filenameId === $orderId){
- //store File ID matches in an array
- $fileMatches[] = $filenameId;
- }
- echo $fileinfo->getFilename() . "<br>";
- }
- $totalImages = count($fileMatches);
- echo '<hr>Total Images found for this ID '.$orderId.' = '.$totalImages;
- echo '<hr>New count for image would be = '. ($totalImages+1);
- ?>
- $user_imgs = count(glob('imgs/*'.$user_id.'*')));
- $orderId = $_GET['orderid'];
- $all_images = glob('uploads/'.$orderId.'*');
- foreach($all_images as $i)
- echo $i . '<br/>';
- $totalImages = count($all_images);
- echo '<hr>Total Images found for this ID '.$orderId.' = '.$totalImages;
- echo '<hr>New count for image would be = '. ($totalImages+1);
- $orderId = $_GET['orderid'];
- $all_images = glob('uploads/'.$orderId.'*');
- $pp = $qc = 0;
- foreach($all_images as $i) {
- if (strpos($i, '-PP.')!==false)
- $pp++;
- elseif (strpos($i, '-QC.')!==false)
- $qc++;
- }
- echo '<hr>Total Images found for this ID '.$orderId.' (PP) = '.$pp;
- echo '<hr>New count for image would be = '. ($pp+1);
- echo '<hr>Total Images found for this ID '.$orderId.' (QC) = '.$qc;
- echo '<hr>New count for image would be = '. ($qc+1);
- <?php
- // note explicitly set here, but in wild it might be int
- $_GET['orderid'] = '100002246';
- if(! isset($_GET['orderid']) || ( isset($_GET['orderid']) && !is_string($_GET['orderid']))
- || (isset($_GET['orderid']) && is_string($_GET['orderid']) && !preg_match('/^[0-9]+$/', $_GET['orderid']))) {
- // don't run script, this isn't a valid ID
- die("We didn't have a good namen");
- }
- foreach (new DirectoryIterator('.') as $fileInfo)
- {
- if($fileInfo->isDot()) continue;
- $parts = preg_split('/-/', $fileInfo->getFilename());
- if(count($parts) != 7)
- {
- echo "Cannot parse this file: ", $fileInfo->getFilename(), PHP_EOL;
- continue;
- }
- $associated_parts = array(
- "id" => (int)$parts[0],
- "count" => (int)$parts[1],
- "date" => $parts[2] . '-' . $parts[3] . '-' . $parts[4],
- "name" => $parts[5],
- "ext" => $parts[6]
- );
- if($associated_parts['id'] == $id)
- {
- $associated_parts['count'] = $associated_parts['count'] + 1;
- $new_file = implode('-', $associated_parts);
- rename($fileInfo->getFilename(), $new_file);
- }
- }
- foreach (new DirectoryIterator('.') as $fileInfo)
- {
- if($fileInfo->isDot()) continue;
- echo $fileInfo->getFileName(), PHP_EOL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement