fork download
  1. <?php
  2. tubeace_header(1);
  3. ?>
  4.  
  5. <div class="wrap">
  6. <h2>Import Videos</h2>
  7.  
  8. <?php
  9.  
  10. //step 3 start ajax import
  11. if( isset($_REQUEST['Submit2']) ){
  12.  
  13. $copy_video_url = $_POST['copy_video_url'];
  14. $copy_sponsor_link_url = $_POST['copy_sponsor_link_url'];
  15.  
  16. //hidden values
  17. $status = $_POST['status'];
  18. $type = $_POST['type'];
  19. $separator = $_POST['separator'];
  20. $field = $_POST['field'];
  21. $data_format = $_POST['data_format'];
  22. $sponsor = $_POST['sponsor'];
  23. $post_category = $_POST['post_category'];
  24. $thumb_source = $_POST['thumb_source'];
  25. $save_thumbs = $_POST['save_thumbs'];
  26. $save_videos = $_POST['save_videos'];
  27. $detect_duration = $_POST['detect_duration'];
  28. $block_dups = $_POST['block_dups'];
  29.  
  30. //error checking
  31. if($data_format=="custom"){
  32.  
  33. //make sure one field selected as title
  34. if ( !in_array("title", $field) && empty($_POST['setall_title']) ) {
  35. $errs.= "<br><span class=\"errormsg\">Select a field as 'title' or enter a set to all value for title.</span>";
  36. $error2=1;
  37. }
  38.  
  39. //make sure one field selected as thumb_url
  40. if ( !in_array("thumb_url", $field) && !in_array("mobile_thumb_url", $field) && !in_array('thumb_url & mobile_thumb_url', $field) && ($thumb_source=="import_file" || $type=="embed")) {
  41. $errs.= "<br><span class=\"errormsg\">Select a field as 'thumb_url', 'mobile_thumb_url' or 'thumb_url & mobile_thumb_url'.</span>";
  42. $error2=1;
  43. }
  44.  
  45. //make sure one field selected as video_url if type == url
  46. if ( (!in_array("video_url", $field) && !in_array("video_url & mobile_video_url", $field)) && $type=="url" && $online==1) {
  47. $errs.= "<br><span class=\"errormsg\">Select a field as 'video_url' or 'video_url & mobile_video_url'.</span>";
  48. $error2=1;
  49. }
  50.  
  51. //make sure one field selected as video_url if type == url
  52. if ( (!in_array("mobile_video_url", $field) && !in_array("video_url & mobile_video_url", $field)) && $type=="url" && $mobile_online==1) {
  53. $errs.= "<br><span class=\"errormsg\">Select a field as 'mobile_video_url' or 'video_url & mobile_video_url'.</span>";
  54. $error2=1;
  55. }
  56.  
  57. //make sure one field selected as embed_code if type == embed
  58. if ( !in_array("embed_code", $field) && $type=="embed" ) {
  59. $errs.= "<br><span class=\"errormsg\">Select a field as 'embed_code'.</span>";
  60. $error2=1;
  61. }
  62.  
  63. //make sure no fields selected twice
  64. $field2 = $field;
  65. foreach($field2 as $val){
  66.  
  67. if((++$field2[$val] > 1) && $val!="none"){
  68. $errs.= "<br><span class=\"errormsg\">$val selected more that once.</span>";
  69. $error2=1;
  70. }
  71. }
  72. }
  73.  
  74. if(!$error2){
  75.  
  76. $fieldJSON = json_encode($field);
  77. $post_category = json_encode($post_category);
  78.  
  79. echo"
  80. <input id='copy_video_url' type='hidden' value='$copy_video_url'>
  81. <input id='copy_sponsor_link_url' type='hidden' value='$copy_sponsor_link_url'>
  82.  
  83. <input id='status' type='hidden' value='$status'>
  84. <input id='type' type='hidden' value='$type'>
  85. <input id='separator' type='hidden' value='$separator'>
  86. <input id='field' type='hidden' value='$fieldJSON'>
  87. <input id='thumb_source' type='hidden' value='$thumb_source'>
  88. <input id='sponsor' type='hidden' value='$sponsor'>
  89. <input id='post_category' type='hidden' value='$post_category'>
  90. <input id='save_thumbs' type='hidden' value='$save_thumbs'>
  91. <input id='save_videos' type='hidden' value='$save_videos'>
  92. <input id='detect_duration' type='hidden' value='$detect_duration'>
  93. <input id='block_dups' type='hidden' value='$block_dups'>";
  94.  
  95. $setall_array = array('post_date','duration','title','description','tags','performers','site','sponsor_link_url','sponsor_link_txt','misc1','misc2','misc3','misc4','misc5');
  96. foreach($setall_array as $value){
  97.  
  98. echo"<input id='$value' type='hidden' value='".$_POST["setall_$value"]."'>";
  99. }
  100.  
  101.  
  102. echo"<div id=\"response\"></div>
  103. <br /><img id=\"loading\" src=\"".plugins_url("tubeace/images/loading32x32.gif")."\">";
  104.  
  105.  
  106. }
  107. }
  108.  
  109. //step 2 - select fields
  110. if(isset($_REQUEST['Submit']) || $error2){
  111.  
  112. $status = $_POST['status'];
  113. $type = $_POST['type'];
  114. $sponsor = $_POST['sponsor'];
  115. $paste_data = $_POST['paste_data'];
  116. $data_format = $_POST['data_format'];
  117. $post_category = $_POST['post_category'];
  118. $separator = $_POST['separator'];
  119. $thumb_source = $_POST['thumb_source'];
  120. $save_thumbs = $_POST['save_thumbs'];
  121. $save_videos = $_POST['save_videos'];
  122. $detect_duration = $_POST['detect_duration'];
  123. $block_dups = $_POST['block_dups'];
  124.  
  125. $tmpName = $_FILES['uploaded']['tmp_name'];
  126. $fileSize = $_FILES['uploaded']['size'];
  127.  
  128. if($separator=="tab"){
  129. $separator = "\t";
  130. } else if($separator=="comma"){
  131. $separator = ",";
  132. } else if($separator=="semicolon"){
  133. $separator = ";";
  134. } else if($separator=="pipe"){
  135. $separator = "|";
  136. }
  137.  
  138. //error checking
  139.  
  140. //only do original error checking if error2 empty
  141. if(!$error2){
  142.  
  143. if($type=="embed" && $thumb_source=="ffmpeg"){
  144. $errs.= $err_import_data = "<br /><span class=\"errormsg\">You cannot Generate Thumbnails from Embed Codes.</span>";
  145. $error=1;
  146. }
  147.  
  148. //check import file or paste data given
  149. if(empty($tmpName) && empty($paste_data)){
  150. $errs.= $err_import_data = "<br /><span class=\"errormsg\">Upload Import File or Paste Import Data.</span>";
  151. $error=1;
  152. }
  153.  
  154. //get import data
  155. if(!empty($tmpName)){//import file
  156.  
  157. $content = file($tmpName);
  158. $firstLine = $content[0];
  159.  
  160. } else { //paste data
  161.  
  162. $content = $paste_data;
  163. $paste_dataArr = explode("\n", $content);
  164. $firstLine = $paste_dataArr[0];
  165. }
  166.  
  167. //make sure data contains separator
  168. if(@substr_count($firstLine, $separator)==0 && empty($err_import_data)){
  169. $errs.= $err_import_data = "<br /><span class=\"errormsg\">Import Data does not contain any Field Separators as selected below.</span>";
  170. $error=1;
  171. }
  172.  
  173. }
  174.  
  175. if(!$error){
  176.  
  177. //get import data
  178. if(!empty($tmpName)){//import file
  179.  
  180. $fp = fopen($tmpName, 'r');
  181. $content = fread($fp, filesize($tmpName));
  182. fclose($fp);
  183.  
  184. } else { //paste data
  185.  
  186. $content = stripslashes($paste_data);
  187. $paste_dataArr = explode("\n", $content);
  188. }
  189.  
  190. $upload_dir = wp_upload_dir();
  191.  
  192. if($error2){
  193. echo"<span class=\"tubeace-errormsg\">You must correct the error(s) below to proceed.</span>";
  194. echo"$errs <br /><br />";
  195.  
  196. //get first line from tubeace-import.txt
  197. $content = file("$upload_dir[basedir]/tubeace-import.txt");
  198. $firstLine = $content[0];
  199.  
  200. //get entire file
  201. $fp = fopen("$upload_dir[basedir]/tubeace-import.txt", 'r');
  202. $content = fread($fp, filesize("$upload_dir[basedir]/tubeace-import.txt"));
  203. fclose($fp);
  204. }
  205.  
  206. //skip only if error2 set
  207. if(!$error2){
  208. //copy/write import file to tubeace-import.txt
  209. if(!empty($tmpName)){
  210. copy($tmpName, "$upload_dir[basedir]/tubeace-import.txt");
  211. }
  212. if(!empty($paste_data)){
  213.  
  214. // Open file to write
  215. $fp = fopen("$upload_dir[basedir]/tubeace-import.txt", 'w+');
  216. fwrite($fp, $content);
  217. fclose($fp);
  218. }
  219. }
  220.  
  221. echo"<form action=\"".admin_url('admin.php?page=tubeace/tubeace-import.php')."\" method=\"POST\">";
  222.  
  223. $field_array = array('video_url','thumb_url','embed_code','title','duration','description','tags','performers','site','sponsor_link_url','sponsor_link_txt','misc1','misc2','misc3','misc4','misc5');
  224.  
  225. if($data_format=="custom"){
  226.  
  227. echo"<span class=\"tubeace-succmsg\">Match the fields in each drop-down menu with the correct data values.</span>";
  228.  
  229. if($thumb_source=="ffmpeg"){
  230. echo"<br /><span class=\"tubeace-succmsg\">Hint: Thumbnail URL options not shown since 'Generate Thumbnails' was selected on previous page.</span>";
  231. }
  232.  
  233. echo"
  234. <table class=\"vertical-form\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  235. <tr><th>Select Field</th><th>Value</th></tr>";
  236.  
  237. $rowcount = 1;
  238. $i = 0;
  239. $lines = explode("\n", $content);
  240. foreach($fields = explode("$separator", $lines[0]) as $key => $val) {
  241.  
  242. print"<tr class=\"tr$rowcount\">\n";
  243. print"<td class=\"center\">\n";
  244. print"<select name=\"field[$i]\" id=\"field[$i]\">\n";
  245. print"<option value=\"none\">-none-</option>\n";
  246.  
  247. //show field values in drop-downs
  248. foreach($field_array as $value){
  249.  
  250. if($field[$i]==$value){
  251. $sel_field = "selected=\"selected\"";
  252. }
  253.  
  254. if($value=="video_url" && $type!="embed"){
  255.  
  256. print"<option value=\"$value\" $sel_field>$value</option>\n";
  257.  
  258. } elseif($value=="video_url & mobile_video_url" && $type!="embed" && $set['enable_mobile']==1){
  259.  
  260. print"<option value=\"$value\" $sel_field>$value</option>\n";
  261.  
  262. } elseif($value=="thumb_url" && $thumb_source!="ffmpeg"){
  263.  
  264. print"<option value=\"$value\" $sel_field>$value</option>\n";
  265.  
  266. } elseif($value=="thumb_url & mobile_thumb_url" && $thumb_source!="ffmpeg" && $set['enable_mobile']==1){
  267.  
  268. print"<option value=\"$value\" $sel_field>$value</option>\n";
  269.  
  270. } elseif($value=="embed_code" && $type=="embed"){
  271. print"<option value=\"$value\" $sel_field>$value</option>\n";
  272.  
  273. } elseif($value=="duration" && $detect_duration!="1"){
  274.  
  275. print"<option value=\"$value\" $sel_field>$value</option>\n";
  276.  
  277. } elseif($value=="mobile_video_url" && $type!="embed" && $set['enable_mobile']==1){
  278.  
  279. print"<option value=\"$value\" $sel_field>$value</option>\n";
  280.  
  281. } elseif($value=="mobile_thumb_url" && $thumb_source!="ffmpeg" && $set['enable_mobile']==1){
  282.  
  283. print"<option value=\"$value\" $sel_field>$value</option>\n";
  284.  
  285. } elseif($value=="title" || $value=="description" || $value=="tags" || $value=="performers" || $value=="site" ||
  286. $value=="sponsor_link_url" || $value=="sponsor_link_txt" || $value=="misc1" || $value=="misc2" || $value=="misc3" ||
  287. $value=="misc4" || $value=="misc5" || $value=="mobile_sponsor_link_url" || $value=="mobile_sponsor_link_txt" ||
  288. $value=="mobile_misc1" || $value=="mobile_misc2" || $value=="mobile_misc3" || $value=="mobile_misc4" || $value=="mobile_misc5" ||
  289. $value=="sponsor_link_url & mobile_sponsor_link_url"){
  290.  
  291. print"<option value=\"$value\" $sel_field>$value</option>\n";
  292. }
  293.  
  294. unset($sel_field);
  295.  
  296. }
  297.  
  298. print"</select>\n";
  299. print"</td>\n";
  300.  
  301. print"<td>$val</td>\n";
  302. print"</tr>\n";
  303.  
  304. $rowcount++;
  305. if($rowcount==3){
  306. $rowcount = 1;
  307. }
  308.  
  309. $i++;
  310. }
  311.  
  312. print"</table>\n";
  313.  
  314. }
  315.  
  316. if($data_format=="tubeace"){
  317.  
  318. echo"<span class=\"tubeace-succmsg\">Verify that the fields match the correct value. If fields do mot match the values, use a correct Tube Ace formated import file.</span>
  319. <table class=\"vertical-form\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  320. <tr><th>Field</th><th>Value</th></tr>";
  321.  
  322. $field_array = array('title','description','video_url','thumb_url','duration','performers','tags','sponsor_link_url','site','mobile_video_url','mobile_sponsor_link_url');
  323.  
  324. $rowcount = 1;
  325. $i = 0;
  326. $lines = explode("\n", $content);
  327. foreach($fields = explode("$separator", $lines[0]) as $key => $val) {
  328.  
  329.  
  330. echo"
  331. <tr class=\"tr$rowcount\">
  332. <td class=\"center\"><b>$field_array[$i]</b><input type=\"hidden\" name=\"field[$i]\" value=\"$field_array[$i]\"></td>
  333. <td>$val</td>
  334. </tr>";
  335.  
  336. $rowcount++;
  337. if($rowcount==3){
  338. $rowcount = 1;
  339. }
  340.  
  341. $i++;
  342.  
  343. }
  344.  
  345. echo"</table>\n";
  346.  
  347.  
  348. if($set[enable_web]==1){
  349.  
  350. echo"<fieldset><legend>Options</legend>";
  351.  
  352. if($i<9){
  353. echo"
  354. <input name=\"copy_video_url\" type=\"checkbox\" class=\"checkbox\" value=\"1\">
  355. Copy <b>video_url</b> value for <b>mobile_video_url</b><br />";
  356. }
  357.  
  358. if($i<10){
  359. echo"
  360. <input name=\"copy_sponsor_link_url\" type=\"checkbox\" class=\"checkbox\" value=\"1\">
  361. Copy <b>sponsor_link_url</b> value for <b>mobile_sponsor_link_url</b>";
  362. }
  363.  
  364. echo"
  365. </fieldset>";
  366. }
  367.  
  368. }
  369.  
  370. //Set All's
  371. print"<br>";
  372. print"<span class=\"tubeace-succmsg\">Below you can set the same values to a field for all entries you are about to import.</span>";
  373. print"<table class=\"vertical-form\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
  374. print"<tr><th class=\"right\"></th><th class=\"left\">Set all fields to this value or leave blank to use value from import file.</th></tr>\n";
  375.  
  376. $setall_array = array('post_date' => '160', 'duration' => '60','title' => '320t','description' => '320','tags' => '320','performers' => '320','site' => '160',
  377. 'sponsor_link_url' => '320t','sponsor_link_txt' => '320t','misc1' => '320','misc2' => '320','misc3' => '320','misc4' => '320',
  378. 'misc5' => '320');
  379. $rowcount = 1;
  380.  
  381. foreach($setall_array as $fieldName => $value){
  382. if( ($type=="embed" && $value!="video_url") || ($type=="url" && $value!="embed_code")){
  383.  
  384. unset($fill_val);
  385. if($fieldName=="sponsor_link_txt" || $fieldName=="mobile_sponsor_link_txt"){
  386. $fill_val = "Click Here for Full Video";
  387. }
  388.  
  389. if($fieldName=="post_date"){
  390. $fill_val = date("Y-m-d H:i:s");
  391. }
  392.  
  393. echo"<tr class=\"tr$rowcount\"><td class=\"right\"><b>$fieldName</b></td><td class=\"left\">";
  394.  
  395. if($value=="60" || $value=="160" || $value=="320t"){
  396.  
  397. //strip t
  398. $value=str_replace("t","",$value);;
  399.  
  400. echo"<input type=\"text\" class=\"input-$value\" name=\"setall_$fieldName\" value=\"$fill_val\">";
  401. } else {
  402. echo"<textarea class=\"input-$value\" name=\"setall_$fieldName\">$fill_val</textarea>";
  403. }
  404.  
  405. if($fieldName=="tags" || $fieldName=="performers"){
  406. print"(separate by comma.)";
  407. }
  408. print"</td></tr>\n";
  409. $rowcount++;
  410. if($rowcount==3){
  411. $rowcount = 1;
  412. }
  413. }
  414. }
  415. print"</table>\n";
  416.  
  417.  
  418. print"<input name=\"status\" type=\"hidden\" value=\"$status\">\n";
  419. print"<input name=\"type\" type=\"hidden\" value=\"$type\">\n";
  420. print"<input name=\"separator\" type=\"hidden\" value=\"$separator\">\n";
  421. print"<input name=\"paste_data\" type=\"hidden\" value=\"".urlencode($paste_data)."\">\n";
  422. print"<input name=\"data_format\" type=\"hidden\" value=\"$data_format\">\n";
  423. print"<input name=\"sponsor\" type=\"hidden\" value=\"$sponsor\">\n";
  424.  
  425. if(!empty($post_category)){
  426. foreach($post_category as $value)
  427. {
  428. echo '<input type="hidden" name="post_category[]" value="'. $value. '">';
  429. }
  430. }
  431.  
  432. echo"<input name=\"thumb_source\" type=\"hidden\" value=\"$thumb_source\">\n";
  433. echo"<input name=\"block_dups\" type=\"hidden\" value=\"$block_dups\">\n";
  434. echo"<input name=\"save_thumbs\" type=\"hidden\" value=\"$save_thumbs\">\n";
  435. echo"<input name=\"detect_duration\" type=\"hidden\" value=\"$detect_duration\">\n";
  436. echo"<input name=\"save_videos\" type=\"hidden\" value=\"$save_videos\">\n";
  437.  
  438. echo"<input class=\"button-primary\" name=\"Submit2\" type=\"submit\" value=\"Import File\">\n";
  439. echo"</form>\n";
  440. }
  441. }
  442.  
  443.  
  444. //step 1 - set options and enter import data
  445. if (!isset($_REQUEST['Submit']) && !isset($_REQUEST['Submit2']) || $error) {
  446.  
  447. if($error){
  448.  
  449. echo"<span class=\"tubeace-errormsg\">You must correct the error(s) below to proceed.</span>";
  450. echo"$errs";
  451.  
  452. $separator = $_POST['separator'];
  453. $paste_data = $_POST['paste_data'];
  454. }
  455.  
  456. ?>
  457.  
  458. <form action="<?php echo admin_url('admin.php?page=tubeace/tubeace-import.php'); ?>" method="post" enctype="multipart/form-data">
  459. <table class="form-table">
  460. <tbody>
  461. <tr>
  462. <th><label for="status">Status</label></th>
  463. <td>
  464. <select name="status" id="status">
  465. <option value="publish">Publish</option>
  466. <option value="pending">Pending</option>
  467. <option value="draft">Draft</option>
  468. <option value="future">Future</option>
  469. <option value="private">Private</option>
  470. </select>
  471. </td>
  472. </tr>
  473. <tr>
  474. <th><label for="type">Video Type</label></th>
  475. <td>
  476. <input type="radio" name="type" id="video_url" value="url" checked> <label for="video_url" class="sel">Video URL (flv or mp4 URL)</label>
  477. <input type="radio" name="type" id="embed_code" value="embed" > <label for="embed_code" class="sel">Embed Code</label>
  478. </td>
  479. </tr>
  480. <tr>
  481. <th><label for="sponsor">Author / Sponsor</label></th>
  482. <td>
  483. <select name="sponsor" id="sponsor">
  484. <?php tubeace_get_users_with_role(array('Contributor','Administrator'),0); ?>
  485. </select>
  486. To add a sponsor, <a href="user-new.php">add a new user</a> with a "Contributor" Role.
  487. </td>
  488. </tr>
  489. <tr>
  490. <th><label for="file">Category</label></th>
  491. <td><ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
  492. <?php wp_category_checklist( $args ); ?></ul>
  493. </td>
  494. </tr>
  495. <tr>
  496. <th><label for="file">Import File</label></th>
  497. <td>
  498. <input type="file" name="uploaded" id="file"><br />
  499. OR Paste below:<br />
  500. <textarea name="paste_data" class="" rows="5"></textarea>
  501. </td>
  502. </tr>
  503. <tr>
  504. <th><label for="file">Data Format</label></th>
  505. <td>
  506. <input type="radio" name="data_format" id="custom_format" value="custom" checked> <label for="custom_format" class="sel">Custom (Select Fields on Next Step)</label>
  507. <input type="radio" name="data_format" id="ta_format" value="tubeace" > <label for="ta_format" class="sel">Tube Ace Format</label>
  508. </td>
  509. </tr>
  510. <tr>
  511. <th><label for="file">Field Separator (delimiter)</label></th>
  512. <td>
  513. <select name="separator">
  514. <option value="pipe" selected="selected" selected="selected">Pipe |</option>
  515. <option value="comma" >Comma ,</option>
  516. <option value="tab" >Tab</option>
  517. <option value="semicolon" >Semicolon ;</option>
  518. </select>
  519. </td>
  520. </tr>
  521. <tr>
  522. <th><label for="">Thumbnail Source</label></th>
  523. <td>
  524. <input type="radio" name="thumb_source" id="use_thumb" value="import_file" checked> <label for="use_thumb" class="sel">Use Thumbnail from Import File</label>
  525. <input type="radio" name="thumb_source" id="gen_thumbs" value="ffmpeg"> <label for="gen_thumbs" class="sel">Generate Thumbnails</label>
  526.  
  527. </td>
  528. </tr>
  529. <tr>
  530. <th><label for="">Save Thumbs from Import File</label></th>
  531. <td>
  532. <input name="save_thumbs" type="checkbox" class="checkbox" id="save_thumbs" value="1" checked/>
  533. </td>
  534. </tr>
  535. <tr>
  536. <th><label for="">Copy and Save Videos to Server</label></th>
  537. <td>
  538. <input name="save_videos" type="checkbox" class="checkbox" id="save_videos" value="1" />
  539. </td>
  540. </tr>
  541. <tr>
  542. <th><label for="">Detect Video Duration</label></th>
  543. <td>
  544. <input name="detect_duration" type="checkbox" class="checkbox" id="detect_duration" value="1" />
  545. </td>
  546. </tr>
  547. <tr>
  548. <th><label for="">Block Duplicates (Video URLs and Embed Codes) from importing into database</label></th>
  549. <td>
  550. <input name="block_dups" type="checkbox" class="checkbox" id="block_dups" value="1" checked/>
  551. </td>
  552. </tr>
  553. </tbody>
  554. </table>
  555. <p class="submit"><input type="submit" value="Next Step" class="button-primary" name="Submit"></p>
  556. </form>
  557.  
  558. <?php
  559.  
  560. }
  561. ?>
  562. </div>
Runtime error #stdin #stdout #stderr 0.01s 82880KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught Error: Call to undefined function tubeace_header() in /home/2FwJP9/prog.php:2
Stack trace:
#0 {main}
  thrown in /home/2FwJP9/prog.php on line 2