Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. foreach (new DirectoryIterator('.') as $item) {
  2. echo $item, PHP_EOL;
  3. }
  4.  
  5. <?php
  6. $orderId = $_GET['orderid'];
  7.  
  8.  
  9. $dir = new DirectoryIterator('uploads');
  10. $fileMatches = array();
  11.  
  12. foreach ($dir as $fileinfo) {
  13.  
  14. $filenameId= substr($fileinfo->getFilename(), 0, 9);
  15.  
  16. if($filenameId === $orderId){
  17. //store File ID matches in an array
  18. $fileMatches[] = $filenameId;
  19. }
  20. echo $fileinfo->getFilename() . "<br>";
  21. }
  22. $totalImages = count($fileMatches);
  23. echo '<hr>Total Images found for this ID '.$orderId.' = '.$totalImages;
  24. echo '<hr>New count for image would be = '. ($totalImages+1);
  25.  
  26. ?>
  27.  
  28. $user_imgs = count(glob('imgs/*'.$user_id.'*')));
  29.  
  30. $orderId = $_GET['orderid'];
  31.  
  32. $all_images = glob('uploads/'.$orderId.'*');
  33.  
  34. foreach($all_images as $i)
  35. echo $i . '<br/>';
  36.  
  37. $totalImages = count($all_images);
  38.  
  39. echo '<hr>Total Images found for this ID '.$orderId.' = '.$totalImages;
  40. echo '<hr>New count for image would be = '. ($totalImages+1);
  41.  
  42. $orderId = $_GET['orderid'];
  43.  
  44. $all_images = glob('uploads/'.$orderId.'*');
  45.  
  46. $pp = $qc = 0;
  47.  
  48. foreach($all_images as $i) {
  49. if (strpos($i, '-PP.')!==false)
  50. $pp++;
  51. elseif (strpos($i, '-QC.')!==false)
  52. $qc++;
  53. }
  54.  
  55. echo '<hr>Total Images found for this ID '.$orderId.' (PP) = '.$pp;
  56. echo '<hr>New count for image would be = '. ($pp+1);
  57.  
  58. echo '<hr>Total Images found for this ID '.$orderId.' (QC) = '.$qc;
  59. echo '<hr>New count for image would be = '. ($qc+1);
  60.  
  61. <?php
  62. // note explicitly set here, but in wild it might be int
  63. $_GET['orderid'] = '100002246';
  64.  
  65. if(! isset($_GET['orderid']) || ( isset($_GET['orderid']) && !is_string($_GET['orderid']))
  66. || (isset($_GET['orderid']) && is_string($_GET['orderid']) && !preg_match('/^[0-9]+$/', $_GET['orderid']))) {
  67. // don't run script, this isn't a valid ID
  68. die("We didn't have a good namen");
  69. }
  70.  
  71. foreach (new DirectoryIterator('.') as $fileInfo)
  72. {
  73. if($fileInfo->isDot()) continue;
  74.  
  75. $parts = preg_split('/-/', $fileInfo->getFilename());
  76.  
  77. if(count($parts) != 7)
  78. {
  79. echo "Cannot parse this file: ", $fileInfo->getFilename(), PHP_EOL;
  80. continue;
  81. }
  82.  
  83. $associated_parts = array(
  84. "id" => (int)$parts[0],
  85. "count" => (int)$parts[1],
  86. "date" => $parts[2] . '-' . $parts[3] . '-' . $parts[4],
  87. "name" => $parts[5],
  88. "ext" => $parts[6]
  89. );
  90.  
  91. if($associated_parts['id'] == $id)
  92. {
  93. $associated_parts['count'] = $associated_parts['count'] + 1;
  94. $new_file = implode('-', $associated_parts);
  95. rename($fileInfo->getFilename(), $new_file);
  96. }
  97. }
  98.  
  99. foreach (new DirectoryIterator('.') as $fileInfo)
  100. {
  101. if($fileInfo->isDot()) continue;
  102. echo $fileInfo->getFileName(), PHP_EOL;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement