<commit_before><?php

if(!defined('_IPATH')) {
    die('<h3>Forbidden</h3>');
}

class CLASS_MODULE_API extends CLASS_MODULE {

  public function __construct() {
    parent::__construct();
  }

  public function CLASS_MODULE_API() { $this->__construct(); }
  
  function doAjax($action) {
    switch($action) {
    case 'wayixia':
      $this->wayixia();
      break;
    case 'wa-image':
      $this->wa_image();
      break;
    case 'wa':
      $this->add_image();
      break;
    case 'public-wa':
      $this->public_image();
      break;
    case 'get-album-list':
      $this->get_album_list();
      break;
    case 'get-album-image-list':
      $this->get_album_image_list();
      break;
    
    // 发布接口
    case 'add-album':
      $this->add_album();
      break;

    default:
      parent::doAjax($action);
    }
  }
  
  function doMain($action) {
    switch($action) {
    case 'preview':
      $this->preview();
      break;
    case 'xdm':
      $this->xdm();
      break;
    default:
      parent::doMain($action);
    }
  }


  function preview() {
    // useralbums
    $sql = "SELECT id as value, name as text FROM  `##__users_albums`";
    $uid = $this->App()->get_user_info('uid');
    if(!empty($uid)) {<commit_msg>reconstruct dig image<commit_after><?php

if(!defined('_IPATH')) {
    die('<h3>Forbidden</h3>');
}

class CLASS_MODULE_API extends CLASS_MODULE {

  public function __construct() {
    parent::__construct();
  }

  public function CLASS_MODULE_API() { $this->__construct(); }
  
  function doAjax($action) {
    switch($action) {
    case 'wayixia':
      $this->wayixia();
      break;
    case 'get-album-list':
      $this->get_album_list();
      break;
    case 'get-album-image-list':
      $this->get_album_image_list();
      break;

    // api for nodejs to get remote image 
    case 'check-wa-image':
      $this->check_wa_image();
      break;
    case 'wa-image':
      $this->wa_image();
      break;      
    // end api for nodejs to get remote image 

    case 'wa':
      $this->add_image();
      break;
    case 'public-wa':
      $this->public_image();
      break;
    
    // 发布接口
    case 'add-album':
      $this->add_album();
      break;

    default:
      parent::doAjax($action);
    }
  }

  // 检查资源是否存在
  function check_wa_image() {
    $theApp = &$this->App();
    $user_key = $theApp->get_user_info('user-key');
    $uid = $theApp->get_user_info('uid');
    if(!$user_key || empty($user_key)) {
      $this->AjaxHeader(-2); // not login
      $this->AjaxData('you must login!');
      return;
    }

    // Ajax 数据
    $data = $_POST['data'];
    $image_srcUrl  = $data['srcUrl'];
    $image_pageUrl = $data['pageUrl'];
    
    $url = parse_url($image_pageUrl);
    $from_host = $url['host'];
    
    $res_id = 0;
    $need_insert = false;
    // 检查是否存在图片资源
    $resource = $db->get_row("select id, file_type, file_name from ##__images_resource where `src`='{$image_srcUrl}' limit 0,1;");
    if(empty($resource)) {
      // 不存在， 可以挖取图片
      $res_id = 0; 
    } else {
      $res_id = $resource['id']; 
      // 资源已经存在，检测来源网页是否重复
      $sql = "select id ";
      $sql.= "from ##__users_images I, ##__users_albums A ";
      $sql.= "where I.albumd_id = A.id and I.res_id={$res_id} and I.from_host='{$from_host}' and A.uid={$uid} ";
      $sql.= "limit 0,1;";
      $image = $db->get_row($check_duplicate);
      $need_insert = empty($image);
    }
    
    $this->AjaxData(array('res_id' => $res_id, 'need_insert' => $need_insert)); 
  }

  function doMain($action) {
    switch($action) {
    case 'preview':
      $this->preview();
      break;
    case 'xdm':
      $this->xdm();
      break;
    default:
      parent::doMain($action);
    }
  }


  function preview() {
    // useralbums
    $sql = "SELECT id as value, name as text FROM  `##__users_albums`";
    $uid = $this->App()->get_user_info('uid');
    if(!empty($uid)) {
{'fraction_non_alphanumeric': 0.17684640940454893, 'fraction_numerical': 0.002811142346026067, 'mean_word_length': 2.469858156028369, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5096284', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1439, 'n_words': 262}