if ($acnastr == 'NA') {
         array_push($nas, $vvv);
     }
 }
 echo "Proceed with file copy? (to homework_{$vv->id}_{$stuid}/) [y/N]:\n";
 if (inputstr() == 'y') {
     $p_file_copy = 1;
     $loop_arr = $problemset;
     @mkdir("homework_{$vv->id}_{$stuid}");
 } else {
     $p_file_copy = 0;
     $loop_arr = $nas;
 }
 foreach ($loop_arr as $vvv) {
     echo "Fetch for {$vvv->vid}-{$vvv->id} : {$vvv->title} ";
     $problem_desc = htmltotext(getproblem($vvv->link));
     echo ".\n";
     $src_flag = 0;
     ready_for_upload:
     if (!file_exists('CProgrammingLanguage-BHH-ZJU/' . $vvv->id . '/' . $vvv->id . '.c')) {
         $src_flag = 1;
         @mkdir('CProgrammingLanguage-BHH-ZJU/' . $vvv->id);
         $desc_searches = array('/\\)\\{/', "/\\)\n\\{/", '/"stdio\\.h"/');
         $desc_replaces = array(') {', ') {', '<stdio.h>');
         $problem_desc = preg_replace($desc_searches, $desc_replaces, $problem_desc);
         file_put_contents("CProgrammingLanguage-BHH-ZJU/{$vvv->id}/README.txt", $vvv->title . "\n\n" . $problem_desc . "\n");
         echo "Terrible >_< File not exist.\n";
         echo "So you should solve this problem: (press Enter/Return key to see the problem)\n";
         waitforret();
         preg_match('/(\\#include[\\s\\S]+)$/', $problem_desc, $matches_src);
         $demo_src = $matches_src[1];
Example #2
0
function get_content($cid, $num, $suffix = true)
{
    $info = M('category')->find($cid);
    $content = htmltotext($info['content']);
    return msubstr($content, 0, $num, 'utf-8', $suffix);
}